last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2570,706 +2570,6 @@ class XCBoxObject : public XCBaseObject
|
||||
CChartObjectRectangle mRect;
|
||||
};
|
||||
|
||||
class XCRRObject : public XCBaseObject
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
/**
|
||||
* Creator ...
|
||||
*
|
||||
* @param chart_id: Long, Specified Chart ID ...
|
||||
* @param window: Integer, Specified Chart Window ID ...
|
||||
* @param rr: XRR instance Reference ...
|
||||
* @param prefix: String ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
int window,
|
||||
XRR &rr,
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = rr.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string name = rr.GetTag();
|
||||
if (IsValid(prefix))
|
||||
{
|
||||
name = prefix + "_" + name;
|
||||
}
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
bool isLong = IsLong(rr.type);
|
||||
|
||||
//
|
||||
double price1 = rr.entry;
|
||||
double price2 = rr.sl;
|
||||
|
||||
//
|
||||
datetime time1 = rr.time;
|
||||
datetime time2 = (datetime)((int)rr.time + 5 * PeriodSeconds(rr.period));
|
||||
|
||||
//
|
||||
result = mFibo.Create(
|
||||
chart_id,
|
||||
name,
|
||||
window,
|
||||
time1,
|
||||
price1,
|
||||
time2,
|
||||
price2 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mRR = rr;
|
||||
ObjName(name);
|
||||
|
||||
//
|
||||
int tpsCount = ArraySize(rr.tps);
|
||||
int levels = tpsCount + 2;
|
||||
result = mFibo.LevelsCount(levels);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Fibo Levels ...
|
||||
|
||||
//
|
||||
result = mFibo.LevelValue(0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = mFibo.LevelDescription(0, "SL");
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mFibo.LevelValue(1, 1.0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = mFibo.LevelDescription(1, "Entry");
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < tpsCount; i++)
|
||||
{
|
||||
//
|
||||
int idx = i + 2;
|
||||
double level = 1.0 + rr.tps[i];
|
||||
string description = "TP " + ToString(rr.tps[i]);
|
||||
|
||||
//
|
||||
result = mFibo.LevelValue(
|
||||
idx,
|
||||
level //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = mFibo.LevelDescription(
|
||||
idx,
|
||||
description //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Virtual ...
|
||||
|
||||
/**
|
||||
* Retrieve Object Type ...
|
||||
*
|
||||
* @return ( ENUM_XCHARTOBJECTS )
|
||||
*/
|
||||
virtual ENUM_XCHARTOBJECTS Type()
|
||||
{
|
||||
return X_RR_OBJ;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
XRR mRR;
|
||||
CChartObjectFibo mFibo;
|
||||
|
||||
//
|
||||
bool SetSLProps(
|
||||
int width = 1,
|
||||
color clr = clrRed,
|
||||
ENUM_LINE_STYLE style = STYLE_SOLID,
|
||||
string description = "" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = SetLevelProps(
|
||||
0,
|
||||
width,
|
||||
clr,
|
||||
style,
|
||||
description //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetEntryProps(
|
||||
int width = 1,
|
||||
color clr = clrOrange,
|
||||
ENUM_LINE_STYLE style = STYLE_SOLID,
|
||||
string description = "" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = SetLevelProps(
|
||||
0,
|
||||
width,
|
||||
clr,
|
||||
style,
|
||||
description //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetTPProps(
|
||||
double tpValue,
|
||||
int width = 1,
|
||||
color clr = clrLime,
|
||||
ENUM_LINE_STYLE style = STYLE_SOLID,
|
||||
string description = "" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int tpIDX = FindIndex(
|
||||
tpValue,
|
||||
mRR.tps //
|
||||
);
|
||||
result = IsValidIndex(tpIDX);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
tpIDX += 2;
|
||||
|
||||
//
|
||||
result = SetLevelProps(
|
||||
tpIDX,
|
||||
width,
|
||||
clr,
|
||||
style,
|
||||
description //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetLevelProps(
|
||||
int id,
|
||||
int width = 1,
|
||||
color clr = clrYellow,
|
||||
ENUM_LINE_STYLE style = STYLE_SOLID,
|
||||
string description = "" //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Color ...
|
||||
result = mFibo.LevelColor(
|
||||
id,
|
||||
clr //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Style ...
|
||||
result = mFibo.LevelStyle(
|
||||
id,
|
||||
style //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Width ...
|
||||
if (width > 0)
|
||||
{
|
||||
//
|
||||
result = mFibo.LevelWidth(
|
||||
id,
|
||||
width //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Description ...
|
||||
if (IsValid(description))
|
||||
{
|
||||
//
|
||||
result = mFibo.LevelDescription(
|
||||
id,
|
||||
description //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
class XCTrendObject : public XCBaseObject
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
/**
|
||||
* Creator ...
|
||||
*
|
||||
* @param chart_id: Long, Specified Chart ID ...
|
||||
* @param window: Integer, Specified Chart Window ID ...
|
||||
* @param rr: XRR instance Reference ...
|
||||
* @param prefix: String ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
int window,
|
||||
XPoint &swings[],
|
||||
bool useMinAsStart = true,
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = ArraySize(swings);
|
||||
result =
|
||||
count >= 2 &&
|
||||
IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double min = 0;
|
||||
datetime minAt = NULL;
|
||||
|
||||
//
|
||||
double max = 0;
|
||||
datetime maxAt = NULL;
|
||||
|
||||
//
|
||||
// Etract Min/Max ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPoint iPoint = swings[i];
|
||||
|
||||
//
|
||||
if (!iPoint.IsValid())
|
||||
{
|
||||
//
|
||||
iPoint.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSetMin =
|
||||
min == 0
|
||||
? true
|
||||
: min > iPoint.value;
|
||||
if (canSetMin)
|
||||
{
|
||||
//
|
||||
minAt = iPoint.at;
|
||||
min = iPoint.value;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSetMax =
|
||||
max == 0
|
||||
? true
|
||||
: max < iPoint.value;
|
||||
if (canSetMax)
|
||||
{
|
||||
//
|
||||
maxAt = iPoint.at;
|
||||
max = iPoint.value;
|
||||
}
|
||||
|
||||
//
|
||||
iPoint.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
double first =
|
||||
useMinAsStart
|
||||
? min
|
||||
: max;
|
||||
datetime firstTime =
|
||||
useMinAsStart
|
||||
? minAt
|
||||
: maxAt;
|
||||
|
||||
//
|
||||
double second =
|
||||
useMinAsStart
|
||||
? max
|
||||
: min;
|
||||
datetime secondTime =
|
||||
useMinAsStart
|
||||
? maxAt
|
||||
: minAt;
|
||||
|
||||
//
|
||||
// Validate Points ...
|
||||
result =
|
||||
//
|
||||
first > 0 &&
|
||||
second > 0 &&
|
||||
(useMinAsStart
|
||||
? first <= second
|
||||
: first >= second) &&
|
||||
IsSpecifiedValid(firstTime) &&
|
||||
IsSpecifiedValid(secondTime)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION dir =
|
||||
useMinAsStart
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
string name = "XTRND" + ToString(dir) + "_" + ToString(first) + "_" + ToString(second);
|
||||
if (IsValid(prefix))
|
||||
{
|
||||
name = prefix + "_" + name;
|
||||
}
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
result = mTrend.Create(
|
||||
chart_id,
|
||||
name,
|
||||
window,
|
||||
firstTime,
|
||||
first,
|
||||
secondTime,
|
||||
second //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjName(name);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creator ...
|
||||
*
|
||||
* @param chart_id: Long, Specified Chart ID ...
|
||||
* @param window: Integer, Specified Chart Window ID ...
|
||||
* @param rr: XRR instance Reference ...
|
||||
* @param prefix: String ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
int window,
|
||||
XSwingPoint &swings[],
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = ArraySize(swings);
|
||||
result =
|
||||
count >= 2 &&
|
||||
IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_SWING_TYPE type = swings[0].type;
|
||||
bool isSwingLows = type == X_SWING_LOW;
|
||||
|
||||
//
|
||||
double values[];
|
||||
int valuesCount = ExtractSwings(
|
||||
swings,
|
||||
values //
|
||||
);
|
||||
result = valuesCount == count;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int firstIDX = -1;
|
||||
double first = 0;
|
||||
datetime firstTime = NULL;
|
||||
|
||||
//
|
||||
int secondIDX = -1;
|
||||
double second = 0;
|
||||
datetime secondTime = NULL;
|
||||
|
||||
//
|
||||
if (isSwingLows)
|
||||
{
|
||||
//
|
||||
first = GetMin(
|
||||
values,
|
||||
firstIDX,
|
||||
0,
|
||||
0 //
|
||||
);
|
||||
if (IsValidIndex(firstIDX))
|
||||
{
|
||||
//
|
||||
firstTime = swings[firstIDX].time;
|
||||
|
||||
//
|
||||
second = FindBiggerThan(
|
||||
first,
|
||||
values,
|
||||
true //
|
||||
);
|
||||
secondIDX = FindIndex(
|
||||
second,
|
||||
values //
|
||||
);
|
||||
if (IsValidIndex(secondIDX))
|
||||
{
|
||||
secondTime = swings[secondIDX].time;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
first = GetMax(
|
||||
values,
|
||||
firstIDX,
|
||||
0,
|
||||
0 //
|
||||
);
|
||||
if (IsValidIndex(firstIDX))
|
||||
{
|
||||
//
|
||||
firstTime = swings[firstIDX].time;
|
||||
|
||||
//
|
||||
second = FindLesserThan(
|
||||
first,
|
||||
values,
|
||||
true //
|
||||
);
|
||||
secondIDX = FindIndex(
|
||||
second,
|
||||
values //
|
||||
);
|
||||
if (IsValidIndex(secondIDX))
|
||||
{
|
||||
secondTime = swings[secondIDX].time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Points ...
|
||||
result =
|
||||
//
|
||||
IsValidIndex(firstIDX) &&
|
||||
IsValidIndex(secondIDX) &&
|
||||
//
|
||||
IsSpecifiedValid(firstTime) &&
|
||||
IsSpecifiedValid(secondTime) &&
|
||||
//
|
||||
(isSwingLows
|
||||
? first < second
|
||||
: first > second)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string name = ToString(type) + "_" + ToString(first) + "_" + ToString(second);
|
||||
if (IsValid(prefix))
|
||||
{
|
||||
name = prefix + "_" + name;
|
||||
}
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
result = mTrend.Create(
|
||||
chart_id,
|
||||
name,
|
||||
window,
|
||||
firstTime,
|
||||
first,
|
||||
secondTime,
|
||||
second //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjName(name);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Trend Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void TrendColor(color value)
|
||||
{
|
||||
mTrend.Color(value);
|
||||
}
|
||||
|
||||
void TrendRayLeft(bool value)
|
||||
{
|
||||
mTrend.RayLeft(value);
|
||||
}
|
||||
|
||||
void TrendRayRight(bool value)
|
||||
{
|
||||
mTrend.RayRight(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Virtual ...
|
||||
|
||||
/**
|
||||
* Retrieve Object Type ...
|
||||
*
|
||||
* @return ( ENUM_XCHARTOBJECTS )
|
||||
*/
|
||||
virtual ENUM_XCHARTOBJECTS Type()
|
||||
{
|
||||
return X_TREND_OBJ;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
CChartObjectTrend mTrend;
|
||||
};
|
||||
|
||||
//
|
||||
// Zone Ticks ...
|
||||
|
||||
|
||||
@@ -2816,123 +2816,6 @@ class XCPOIDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Trend Line Object ...
|
||||
*
|
||||
* @param swings: XSwingPoint instance Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateTrend(
|
||||
XSwingPoint &swings[],
|
||||
XCTrendObject *&object //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
object = NULL;
|
||||
|
||||
//
|
||||
result = ArraySize(swings) >= 2 &&
|
||||
IsValidSize(ArraySize(swings));
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
object = new XCTrendObject();
|
||||
result = object.Create(
|
||||
chartID,
|
||||
window,
|
||||
swings,
|
||||
prefix //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
color clrTrend = swings[0].type == X_SWING_LOW
|
||||
? SwingLowColor()
|
||||
: SwingHighColor();
|
||||
object.TrendColor(clrTrend);
|
||||
object.TrendRayRight(true);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Trend Line Object ...
|
||||
*
|
||||
* @param swings: XSwingPoint instance Collection ...
|
||||
* @param useMinAsStart: Specified Min Value as Start ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateTrend(
|
||||
XPoint &swings[],
|
||||
XCTrendObject *&object,
|
||||
bool useMinAsStart = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
object = NULL;
|
||||
|
||||
//
|
||||
result = ArraySize(swings) >= 2 &&
|
||||
IsValidSize(ArraySize(swings));
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
object = new XCTrendObject();
|
||||
result = object.Create(
|
||||
chartID,
|
||||
window,
|
||||
swings,
|
||||
useMinAsStart,
|
||||
prefix //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
color clrTrend = useMinAsStart
|
||||
? SwingLowColor()
|
||||
: SwingHighColor();
|
||||
object.TrendColor(clrTrend);
|
||||
object.TrendRayRight(true);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Consolidation Zone Object ...
|
||||
*
|
||||
@@ -3376,53 +3259,6 @@ class XCPOIDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Specific Risk Reward (RR) on Chart ...
|
||||
*
|
||||
* @param rr: XRR instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateRR(
|
||||
XRR &rr,
|
||||
XCRRObject *&object //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
object = NULL;
|
||||
|
||||
//
|
||||
result = rr.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
object = new XCRRObject();
|
||||
result = object.Create(
|
||||
chartID,
|
||||
window,
|
||||
rr,
|
||||
prefix //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Signal ...
|
||||
*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2981,6 +2981,117 @@ if (useSenario1)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// FRACTALS ...
|
||||
int copiedFractalsUppers = CopyBuffer(fractalHandler, 0, UPPER_LINE, limit, fractalsUpperBuffer);
|
||||
int copiedFractalsLowers = CopyBuffer(fractalHandler, 1, LOWER_LINE, limit, fractalsLowerBuffer);
|
||||
|
||||
//
|
||||
// FRACTALS ...
|
||||
copiedFractalsUppers > 0 &&
|
||||
copiedFractalsLowers > 0
|
||||
|
||||
//
|
||||
// FRACTALS ...
|
||||
int fractalsCalculatedBars = BarsCalculated(fractalHandler);
|
||||
|
||||
//
|
||||
// FRACTALS ...
|
||||
fractalsCalculatedBars >= maxLength
|
||||
|
||||
|
||||
//
|
||||
// SUPPORT and RESISTANCE ...
|
||||
|
||||
//
|
||||
double iHighValue = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
barIndex //
|
||||
);
|
||||
double iLastHighValue = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
lastIndex //
|
||||
);
|
||||
|
||||
//
|
||||
double iLowValue = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
barIndex //
|
||||
);
|
||||
double iLastLowValue = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
lastIndex //
|
||||
);
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
// double lastResistance =
|
||||
// lastIndex < barsCount
|
||||
// ? resistancesBuffer[lastIndex]
|
||||
// : iLastHighValue;
|
||||
// double iFractalsUpper = fractalsUpperBuffer[barIndex];
|
||||
// double iResistance =
|
||||
// NotEmptyZero(iFractalsUpper)
|
||||
// ? iHighValue
|
||||
// : lastResistance;
|
||||
// resistancesBuffer[barIndex] = iResistance;
|
||||
|
||||
//
|
||||
// Support ...
|
||||
// double lastSupport =
|
||||
// lastIndex < barsCount
|
||||
// ? supportsBuffer[lastIndex]
|
||||
// : iLastLowValue;
|
||||
// double iFractalsLower = fractalsLowerBuffer[barIndex];
|
||||
// double iSupport =
|
||||
// NotEmptyZero(iFractalsLower)
|
||||
// ? iLowValue
|
||||
// : lastSupport;
|
||||
// supportsBuffer[barIndex] = iSupport;
|
||||
|
||||
//
|
||||
double iFractalsUpper = fractalsUpperBuffer[barIndex];
|
||||
double iResistance = iFractalsUpper;
|
||||
resistancesBuffer[barIndex] = iResistance;
|
||||
|
||||
|
||||
//
|
||||
double iFractalsLower = fractalsLowerBuffer[barIndex];
|
||||
double iSupport = iFractalsLower;
|
||||
supportsBuffer[barIndex] = iSupport;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,129 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| x-saherelm.xpoi.test.ea.mq5 |
|
||||
//| SaherElm IT Center |
|
||||
//| https://www.saherelm.ir |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
|
||||
//
|
||||
// #include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
// #include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
||||
// #include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
|
||||
// #include "../Libraries/x-saherelm.x-poi.state.lib.mq5"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
|
||||
//
|
||||
// Global Variables ...
|
||||
|
||||
//
|
||||
// XCPOIDrawer *mPOIDrawer;
|
||||
|
||||
//
|
||||
// XCPOIDetector *mPOIDetector;
|
||||
XCBarAnalyser *mBarAnalyser;
|
||||
|
||||
//
|
||||
bool useDetector = false;
|
||||
bool useBarAnalyser = true;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// mPOIDetector = new XCPOIDetector(
|
||||
// _Symbol,
|
||||
// _Period //
|
||||
// );
|
||||
|
||||
//
|
||||
// mPOIDrawer = new XCPOIDrawer();
|
||||
|
||||
//
|
||||
mBarAnalyser = new XCBarAnalyser();
|
||||
|
||||
//
|
||||
return (INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert deinitialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// ZeroMemory(mPOIDrawer);
|
||||
// ZeroMemory(mPOIDetector);
|
||||
ZeroMemory(mBarAnalyser);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert tick function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
DetectBarAnalyser();
|
||||
|
||||
//
|
||||
DetectPOIState();
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom Functions |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* Detect POI(s) Using Bar Analyser Class ...
|
||||
*/
|
||||
void DetectBarAnalyser()
|
||||
{
|
||||
//
|
||||
if (!useBarAnalyser)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
bool isInited = zBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
0 //
|
||||
);
|
||||
|
||||
//
|
||||
XOHCL toBar;
|
||||
XOHCL fromBar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
bool isSpike = mBarAnalyser.IsSpike(
|
||||
zBar,
|
||||
fromBar,
|
||||
toBar,
|
||||
dir //
|
||||
);
|
||||
if (isSpike)
|
||||
{
|
||||
Print("Spike Detected ...");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect POI(s) Using POIDetector Class ...
|
||||
*/
|
||||
void DetectPOIState()
|
||||
{
|
||||
//
|
||||
if (!useDetector)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "../Helpers/x-saherelm.x121.xmas.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xpv.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xstr.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xtrend.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xvwap.helper.mq5"
|
||||
|
||||
//
|
||||
@@ -51,7 +50,6 @@ struct X121Inputs
|
||||
X121XDONInputs xdonInputs;
|
||||
X121X3MAInputs x3maInputs;
|
||||
X121XVWAPInputs xvwapInputs;
|
||||
X121XTRENDInputs xtrendInputs;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -78,7 +76,6 @@ struct X121Inputs
|
||||
xcheInputs.Clean();
|
||||
xdonInputs.Clean();
|
||||
xvwapInputs.Clean();
|
||||
xtrendInputs.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
@@ -100,7 +97,6 @@ struct X121Inputs
|
||||
xdonInputs.Default();
|
||||
x3maInputs.Default();
|
||||
xvwapInputs.Default();
|
||||
xtrendInputs.Default();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,8 +120,7 @@ struct X121Inputs
|
||||
xstrInputs.IsValid() &&
|
||||
xcheInputs.IsValid() &&
|
||||
xdonInputs.IsValid() &&
|
||||
xvwapInputs.IsValid() &&
|
||||
xtrendInputs.IsValid()
|
||||
xvwapInputs.IsValid()
|
||||
//
|
||||
;
|
||||
|
||||
@@ -152,7 +147,6 @@ struct X121Inputs
|
||||
int xcheMax = xcheInputs.Max();
|
||||
int xdonMax = xdonInputs.Max();
|
||||
int xvwapMax = xvwapInputs.Max();
|
||||
int xtrendMax = xtrendInputs.Max();
|
||||
|
||||
//
|
||||
result = MathMax(xpvMax, xhkMax);
|
||||
@@ -162,7 +156,6 @@ struct X121Inputs
|
||||
result = MathMax(result, xcheMax);
|
||||
result = MathMax(result, xdonMax);
|
||||
result = MathMax(result, xvwapMax);
|
||||
result = MathMax(result, xtrendMax);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -2431,7 +2424,6 @@ class XCX121Helper : public XCBase
|
||||
XCX121XDONHelper *xdonHelper;
|
||||
XCX121X3MAHelper *x3maHelper;
|
||||
XCX121XVWAPHelper *xvwapHelper;
|
||||
XCX121XTRENDHelper *xtrendHelper;
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
@@ -2455,7 +2447,6 @@ class XCX121Helper : public XCBase
|
||||
xcheInputs.Clean();
|
||||
x3maInputs.Clean();
|
||||
xvwapInputs.Clean();
|
||||
xtrendInputs.Clean();
|
||||
|
||||
//
|
||||
delete xccHelper;
|
||||
@@ -2468,7 +2459,6 @@ class XCX121Helper : public XCBase
|
||||
delete xdonHelper;
|
||||
delete x3maHelper;
|
||||
delete xvwapHelper;
|
||||
delete xtrendHelper;
|
||||
|
||||
//
|
||||
ZeroMemory(xccHelper);
|
||||
@@ -2481,7 +2471,6 @@ class XCX121Helper : public XCBase
|
||||
ZeroMemory(xdonHelper);
|
||||
ZeroMemory(x3maHelper);
|
||||
ZeroMemory(xvwapHelper);
|
||||
ZeroMemory(xtrendHelper);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2546,7 +2535,6 @@ class XCX121Helper : public XCBase
|
||||
xdonInputs = inputs.xdonInputs;
|
||||
x3maInputs = inputs.x3maInputs;
|
||||
xvwapInputs = inputs.xvwapInputs;
|
||||
xtrendInputs = inputs.xtrendInputs;
|
||||
|
||||
//
|
||||
// Initial Helpers ...
|
||||
@@ -2681,19 +2669,6 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
xtrendHelper = new XCX121XTRENDHelper();
|
||||
result = xtrendHelper.Init(
|
||||
symbol,
|
||||
period,
|
||||
xtrendInputs //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (inputs.showRSI)
|
||||
{
|
||||
@@ -2918,28 +2893,6 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
bool GetTrendConditions(
|
||||
X121XTRENDConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = xtrendHelper.GetConditions(
|
||||
conditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void Free()
|
||||
{
|
||||
@@ -2952,7 +2905,6 @@ class XCX121Helper : public XCBase
|
||||
xcheHelper.Free();
|
||||
xdonHelper.Free();
|
||||
xvwapHelper.Free();
|
||||
xtrendHelper.Free();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3138,19 +3090,6 @@ class XCX121Helper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
X121XTRENDConditions xtrendConditions;
|
||||
result = GetTrendConditions(
|
||||
xtrendConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill Volume Buffer ...
|
||||
for (int i = barIndex; i < barIndex + loopback; i++)
|
||||
@@ -3422,66 +3361,6 @@ class XCX121Helper : public XCBase
|
||||
conditions.masLowerBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.upTrendBuffer,
|
||||
conditions.upTrendBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.downTrendBuffer,
|
||||
conditions.downTrendBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.maBuffer,
|
||||
conditions.maBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.adxBuffer,
|
||||
conditions.adxBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.adxPBuffer,
|
||||
conditions.adxPBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.adxMBuffer,
|
||||
conditions.adxMBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.upTBuffer,
|
||||
conditions.upTBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
xtrendConditions.downTBuffer,
|
||||
conditions.downTBuffer //
|
||||
);
|
||||
|
||||
//
|
||||
conditions.isTrendBullish = xtrendConditions.isTrendBullish;
|
||||
conditions.isTrendBearish = xtrendConditions.isTrendBearish;
|
||||
conditions.isTrendSwitchedToBullish = xtrendConditions.isTrendSwitchedToBullish;
|
||||
conditions.isTrendSwitchedToBearish = xtrendConditions.isTrendSwitchedToBearish;
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
|
||||
@@ -4594,7 +4473,6 @@ class XCX121Helper : public XCBase
|
||||
xdonConditions.Clean();
|
||||
x3maConditions.Clean();
|
||||
xvwapConditions.Clean();
|
||||
xtrendConditions.Clean();
|
||||
|
||||
//
|
||||
Free();
|
||||
@@ -4628,7 +4506,6 @@ class XCX121Helper : public XCBase
|
||||
X121XCHEInputs xcheInputs;
|
||||
X121X3MAInputs x3maInputs;
|
||||
X121XVWAPInputs xvwapInputs;
|
||||
X121XTRENDInputs xtrendInputs;
|
||||
|
||||
//
|
||||
int mRSIHandler;
|
||||
|
||||
@@ -126,22 +126,22 @@ struct X121XPVInputs
|
||||
{
|
||||
//
|
||||
// Short ...
|
||||
scMethod = X_PERIOD_NOTHING;
|
||||
scMethod = X_PERIOD_NONE;
|
||||
scPeriod = NULL;
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
mcMethod = X_PERIOD_NOTHING;
|
||||
mcMethod = X_PERIOD_NONE;
|
||||
mcPeriod = NULL;
|
||||
|
||||
//
|
||||
// Long ...
|
||||
lcMethod = X_PERIOD_NOTHING;
|
||||
lcMethod = X_PERIOD_NONE;
|
||||
lcPeriod = NULL;
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
hcMethod = X_PERIOD_NOTHING;
|
||||
hcMethod = X_PERIOD_NONE;
|
||||
hcPeriod = NULL;
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Forex Sessions and Day Range Indicator |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Your Name"
|
||||
#property link "https://www.example.com"
|
||||
#property version "1.00"
|
||||
#property indicator_chart_window
|
||||
|
||||
#include <Arrays\ArrayObj.mqh>
|
||||
|
||||
struct SessionInfo {
|
||||
string name;
|
||||
int startHour; // Standard start hour (GMT)
|
||||
int startMinute;
|
||||
int endHour; // Standard end hour (GMT)
|
||||
int endMinute;
|
||||
bool *isDST(datetime); // DST check function
|
||||
int dstAdjustment; // Hours to add during DST
|
||||
};
|
||||
|
||||
SessionInfo sessions[] = {
|
||||
{"Sydney", 21, 0, 5, 0, IsSydneyDST, 1},
|
||||
{"Tokyo", 23, 0, 8, 0, IsTokyoDST, 0},
|
||||
{"London", 7, 0, 15, 0, IsLondonDST, 1},
|
||||
{"New York", 12, 0, 17, 0, IsNewYorkDST, 1}
|
||||
};
|
||||
|
||||
bool sessionActive[];
|
||||
double sessionHigh[];
|
||||
double sessionLow[];
|
||||
datetime sessionStartTime[];
|
||||
datetime sessionEndTime[];
|
||||
|
||||
double dayHigh = 0;
|
||||
double dayLow = 0;
|
||||
datetime dayStartTime;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit() {
|
||||
ArrayResize(sessionActive, ArraySize(sessions));
|
||||
ArrayResize(sessionHigh, ArraySize(sessions));
|
||||
ArrayResize(sessionLow, ArraySize(sessions));
|
||||
ArrayResize(sessionStartTime, ArraySize(sessions));
|
||||
ArrayResize(sessionEndTime, ArraySize(sessions));
|
||||
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
sessionActive[i] = false;
|
||||
sessionHigh[i] = 0;
|
||||
sessionLow[i] = 0;
|
||||
sessionStartTime[i] = 0;
|
||||
sessionEndTime[i] = 0;
|
||||
}
|
||||
|
||||
dayHigh = 0;
|
||||
dayLow = 0;
|
||||
dayStartTime = 0;
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Custom indicator iteration function |
|
||||
//+------------------------------------------------------------------+
|
||||
int OnCalculate(const int rates_total,
|
||||
const int prev_calculated,
|
||||
const datetime &time[],
|
||||
const double &open[],
|
||||
const double &high[],
|
||||
const double &low[],
|
||||
const double &close[],
|
||||
const long &tick_volume[],
|
||||
const long &volume[],
|
||||
const int &spread[]) {
|
||||
datetime currentTime = TimeCurrent();
|
||||
|
||||
// Check each session
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
SessionInfo session = sessions[i];
|
||||
bool dstActive = session.isDST(currentTime);
|
||||
int adjStartHour = session.startHour + (dstActive ? session.dstAdjustment : 0);
|
||||
int adjEndHour = session.endHour + (dstActive ? session.dstAdjustment : 0);
|
||||
|
||||
datetime todayStart = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(adjStartHour) + ":" +
|
||||
IntegerToString(session.startMinute));
|
||||
datetime todayEnd = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(adjEndHour) + ":" +
|
||||
IntegerToString(session.endMinute));
|
||||
|
||||
// Handle sessions spanning midnight
|
||||
if(adjEndHour < adjStartHour) {
|
||||
todayEnd += 24 * 3600;
|
||||
}
|
||||
|
||||
if(currentTime >= todayStart && currentTime < todayEnd) {
|
||||
if(!sessionActive[i]) {
|
||||
sessionActive[i] = true;
|
||||
sessionStartTime[i] = todayStart;
|
||||
sessionEndTime[i] = todayEnd;
|
||||
sessionHigh[i] = Bid;
|
||||
sessionLow[i] = Ask;
|
||||
} else {
|
||||
if(Bid > sessionHigh[i]) sessionHigh[i] = Bid;
|
||||
if(Ask < sessionLow[i]) sessionLow[i] = Ask;
|
||||
}
|
||||
} else {
|
||||
sessionActive[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check day range
|
||||
bool dstActiveNY = IsNewYorkDST(currentTime);
|
||||
int dayStartHour = dstActiveNY ? 21 : 22;
|
||||
datetime todayDayStart = StringToTime(TimeToString(currentTime, TIME_DATE) + " " +
|
||||
IntegerToString(dayStartHour) + ":00");
|
||||
|
||||
if(currentTime < todayDayStart) {
|
||||
todayDayStart -= 24 * 3600;
|
||||
}
|
||||
|
||||
if(dayStartTime != todayDayStart) {
|
||||
dayStartTime = todayDayStart;
|
||||
dayHigh = Bid;
|
||||
dayLow = Ask;
|
||||
} else {
|
||||
if(Bid > dayHigh) dayHigh = Bid;
|
||||
if(Ask < dayLow) dayLow = Ask;
|
||||
}
|
||||
|
||||
// Display information on chart
|
||||
string comment = "Active Forex Sessions:\n";
|
||||
for(int i=0; i<ArraySize(sessions); i++) {
|
||||
if(sessionActive[i]) {
|
||||
comment += sessions[i].name + " Session\n" +
|
||||
"High: " + DoubleToString(sessionHigh[i], _Digits) + "\n" +
|
||||
"Low: " + DoubleToString(sessionLow[i], _Digits) + "\n";
|
||||
}
|
||||
}
|
||||
comment += "\nDay Range:\n" +
|
||||
"High: " + DoubleToString(dayHigh, _Digits) + "\n" +
|
||||
"Low: " + DoubleToString(dayLow, _Digits);
|
||||
Comment(comment);
|
||||
|
||||
return(rates_total);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| DST Check Functions |
|
||||
//+------------------------------------------------------------------+
|
||||
bool IsLondonDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime march31 = StringToTime(year + ".03.31 00:00");
|
||||
int lastSundayMarch = TimeDay(march31) - (TimeDayOfWeek(march31) % 7);
|
||||
datetime dstStart = StringToTime(year + ".03." + IntegerToString(lastSundayMarch) + " 01:00");
|
||||
|
||||
datetime oct31 = StringToTime(year + ".10.31 00:00");
|
||||
int lastSundayOct = TimeDay(oct31) - (TimeDayOfWeek(oct31) % 7);
|
||||
datetime dstEnd = StringToTime(year + ".10." + IntegerToString(lastSundayOct) + " 01:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsNewYorkDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime march1 = StringToTime(year + ".03.01 00:00");
|
||||
int dayOfWeekMarch1 = TimeDayOfWeek(march1);
|
||||
int secondSundayMarch = 1 + (7 - dayOfWeekMarch1) % 7 + 7;
|
||||
datetime dstStart = StringToTime(year + ".03." + IntegerToString(secondSundayMarch) + " 07:00");
|
||||
|
||||
datetime nov1 = StringToTime(year + ".11.01 00:00");
|
||||
int dayOfWeekNov1 = TimeDayOfWeek(nov1);
|
||||
int firstSundayNov = 1 + (7 - dayOfWeekNov1) % 7;
|
||||
datetime dstEnd = StringToTime(year + ".11." + IntegerToString(firstSundayNov) + " 06:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsSydneyDST(datetime time) {
|
||||
int year = TimeYear(time);
|
||||
datetime oct1 = StringToTime(year + ".10.01 00:00");
|
||||
int dayOfWeekOct1 = TimeDayOfWeek(oct1);
|
||||
int firstSundayOct = 1 + (7 - dayOfWeekOct1) % 7;
|
||||
datetime dstStart = StringToTime(year + ".10." + IntegerToString(firstSundayOct) + " 13:00");
|
||||
|
||||
datetime apr1 = StringToTime(year + ".04.01 00:00");
|
||||
int dayOfWeekApr1 = TimeDayOfWeek(apr1);
|
||||
int firstSundayApr = 1 + (7 - dayOfWeekApr1) % 7;
|
||||
datetime dstEnd = StringToTime(year + ".04." + IntegerToString(firstSundayApr) + " 15:00");
|
||||
|
||||
return time >= dstStart && time < dstEnd;
|
||||
}
|
||||
|
||||
bool IsTokyoDST(datetime time) {
|
||||
return false;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+3
-10755
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Common Library
|
||||
// --------------------------------------
|
||||
// Name: XModelsLib
|
||||
// Description: provide all commonly used functions ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#include "../Libraries/x-saherelm.common.extensions.lib.mq5"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -239,7 +239,7 @@ ENUM_X_POSITION_TYPES ToPositionType(ENUM_POSITION_TYPE value)
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_POSITION_TYPES GetOppositPositionType(ENUM_POSITION_TYPE type)
|
||||
ENUM_X_POSITION_TYPES OppositPositionType(ENUM_POSITION_TYPE type)
|
||||
{
|
||||
//
|
||||
ENUM_X_POSITION_TYPES result = X_POSITION_TYPE_NONE;
|
||||
@@ -1567,7 +1567,7 @@ struct XSignal
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_POSITION_TYPE mType = GetOpposit(this.type);
|
||||
ENUM_POSITION_TYPE mType = Opposit(this.type);
|
||||
double mEntry = GetExit(this.symbol, mType);
|
||||
|
||||
//
|
||||
@@ -1615,7 +1615,7 @@ struct XSignal
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
ENUM_POSITION_TYPE mType = GetOpposit(source.type);
|
||||
ENUM_POSITION_TYPE mType = Opposit(source.type);
|
||||
double mEntry = GetEntry(source.symbol, mType);
|
||||
|
||||
//
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1159,7 +1159,13 @@ struct X121SMCStrategySignalProviderData
|
||||
// Prepare all ...
|
||||
bool Prepare(
|
||||
int barIndex = 0,
|
||||
int loopback = 10 //
|
||||
int loopback = 10,
|
||||
bool trigger = false,
|
||||
bool decision = true,
|
||||
bool analyse = true,
|
||||
bool verification = false,
|
||||
bool consolidation = true,
|
||||
bool vision = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1186,169 +1192,192 @@ struct X121SMCStrategySignalProviderData
|
||||
|
||||
//
|
||||
// Trigger ...
|
||||
result = triggerCycleHelper.GetConditions(
|
||||
triggerCycleEvents,
|
||||
triggerPoiEvents,
|
||||
triggerConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (trigger)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
result = triggerCycleHelper.GetConditions(
|
||||
triggerCycleEvents,
|
||||
triggerPoiEvents,
|
||||
triggerConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
|
||||
//
|
||||
triggerConditions.Clean();
|
||||
//
|
||||
triggerConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
result = decisionCycleHelper.GetConditions(
|
||||
decisionCycleEvents,
|
||||
decisionPoiEvents,
|
||||
decisionConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (decision)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
result = decisionCycleHelper.GetConditions(
|
||||
decisionCycleEvents,
|
||||
decisionPoiEvents,
|
||||
decisionConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
result = analyseCycleHelper.GetConditions(
|
||||
analyseCycleEvents,
|
||||
analysePoiEvents,
|
||||
analyseConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (analyse)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
result = analyseCycleHelper.GetConditions(
|
||||
analyseCycleEvents,
|
||||
analysePoiEvents,
|
||||
analyseConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Verification ...
|
||||
result = verificationCycleHelper.GetConditions(
|
||||
verificationCycleEvents,
|
||||
verificationPoiEvents,
|
||||
verificationConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (verification)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
result = verificationCycleHelper.GetConditions(
|
||||
verificationCycleEvents,
|
||||
verificationPoiEvents,
|
||||
verificationConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
result = consolidationCycleHelper.GetConditions(
|
||||
consolidationCycleEvents,
|
||||
consolidationPoiEvents,
|
||||
consolidationConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (consolidation)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
Clean(consolidationCycleEvents);
|
||||
consolidationConditions.Clean();
|
||||
result = consolidationCycleHelper.GetConditions(
|
||||
consolidationCycleEvents,
|
||||
consolidationPoiEvents,
|
||||
consolidationConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
Clean(consolidationCycleEvents);
|
||||
consolidationConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
result = visionCycleHelper.GetConditions(
|
||||
visionCycleEvents,
|
||||
visionPoiEvents,
|
||||
visionConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
if (vision)
|
||||
{
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(visionCycleEvents);
|
||||
visionConditions.Clean();
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
Clean(consolidationCycleEvents);
|
||||
consolidationConditions.Clean();
|
||||
result = visionCycleHelper.GetConditions(
|
||||
visionCycleEvents,
|
||||
visionPoiEvents,
|
||||
visionConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(triggerPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(visionCycleEvents);
|
||||
visionConditions.Clean();
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(triggerCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
triggerConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
Clean(decisionCycleEvents);
|
||||
decisionConditions.Clean();
|
||||
Clean(verificationPoiEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
Clean(verificationCycleEvents);
|
||||
verificationConditions.Clean();
|
||||
Clean(consolidationCycleEvents);
|
||||
consolidationConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2593,7 +2622,6 @@ struct X121SMCStrategyConditionParser
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
@@ -2602,21 +2630,16 @@ struct X121SMCStrategyConditionParser
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
cXConditions.isSMHKSwitchedToBullish &&
|
||||
(
|
||||
//
|
||||
// Validate CBar ...
|
||||
cBar.IsBullish() &&
|
||||
cXConditions.supportsBuffer[cIDX] == cXConditions.valesBuffer[zIDX]
|
||||
//
|
||||
(cBar.low >= cXConditions.valesGoldenBuffer[cIDX] ||
|
||||
(cBar.low < cXConditions.valesGoldenBuffer[cIDX] &&
|
||||
cXConditions.isSarSwitchedToBullish)) &&
|
||||
//
|
||||
(cBar.open == cXConditions.xhkSMOpenBuffer[cIDX] ||
|
||||
(cBar.low < cXConditions.xhkSMLowBuffer[cIDX] &&
|
||||
cBar.GetDown() > cXConditions.xhkSMHighBuffer[cIDX])) &&
|
||||
//
|
||||
cXConditions.isSarBullish
|
||||
// cXConditions.isSarSwitchedToBullish &&
|
||||
// cXConditions.isSMHKSwitchedToBullish &&
|
||||
// cBar.low < cXConditions.masLowerBuffer[cIDX] &&
|
||||
// cBar.low < cXConditions.valesGoldenBuffer[cIDX] &&
|
||||
// zBar.close < cXConditions.valesGoldenBuffer[cIDX] &&
|
||||
// cXConditions.xhkSMCloseBuffer[cIDX] < cXConditions.valesGoldenBuffer[cIDX]
|
||||
//
|
||||
)
|
||||
//
|
||||
@@ -2627,21 +2650,9 @@ struct X121SMCStrategyConditionParser
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
cXConditions.isSMHKSwitchedToBearish &&
|
||||
(
|
||||
//
|
||||
// Validate CBar ...
|
||||
cBar.IsBearish() &&
|
||||
//
|
||||
(cBar.high <= cXConditions.peaksGoldenBuffer[cIDX] ||
|
||||
(cBar.high > cXConditions.peaksGoldenBuffer[cIDX] &&
|
||||
cXConditions.isSarSwitchedToBearish)) &&
|
||||
//
|
||||
(cBar.open == cXConditions.xhkSMOpenBuffer[cIDX] ||
|
||||
(cBar.high > cXConditions.xhkSMHighBuffer[cIDX] &&
|
||||
cBar.GetUp() < cXConditions.xhkSMLowBuffer[cIDX])) &&
|
||||
//
|
||||
cXConditions.isSarBearish
|
||||
false
|
||||
//
|
||||
)
|
||||
//
|
||||
|
||||
@@ -117,7 +117,13 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
// Cycles Conditions ...
|
||||
result = provider.Prepare(
|
||||
zIndex,
|
||||
loopback //
|
||||
loopback,
|
||||
false, // Trigger ...
|
||||
true, // Decision ...
|
||||
true, // Analyse ...
|
||||
true, // Verification ...
|
||||
true, // Consolidation ...
|
||||
true // Vision ...
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
|
||||
@@ -1002,7 +1002,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
// ---------------------------------------------
|
||||
// XPVHK Conditions ...
|
||||
// ---------------------------------------------
|
||||
bool useSenario1 = false;
|
||||
bool useSenario1 = true;
|
||||
bool isSenario1Happend = false;
|
||||
bool isSenario1Bullish = false;
|
||||
bool isSenario1Bearish = false;
|
||||
|
||||
@@ -784,12 +784,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// XCC ...
|
||||
x121Inputs.xccInputs.showCandles = showAll || true;
|
||||
|
||||
//
|
||||
// XTREND ...
|
||||
x121Inputs.xtrendInputs.showUpTrend = showAll || false;
|
||||
x121Inputs.xtrendInputs.showDownTrend = showAll || false;
|
||||
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
x121Inputs.xpvInputs.showSar = showAll || true;
|
||||
|
||||
Reference in New Issue
Block a user