This commit is contained in:
2025-03-14 17:44:33 +03:30
parent fe7df78f5d
commit a05b8f464d
25 changed files with 32729 additions and 17459 deletions
File diff suppressed because it is too large Load Diff
-700
View File
@@ -2570,706 +2570,6 @@ class XCBoxObject : public XCBaseObject
CChartObjectRectangle mRect; 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 ... // Zone Ticks ...
-164
View File
@@ -2816,123 +2816,6 @@ class XCPOIDrawer : public XCBase
return result; 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 ... * Create Consolidation Zone Object ...
* *
@@ -3376,53 +3259,6 @@ class XCPOIDrawer : public XCBase
return result; 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 ... * Draw Specified Signal ...
* *
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+111
View File
@@ -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
+129
View File
@@ -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;
}
}
//
//+------------------------------------------------------------------+
+1 -124
View File
@@ -31,7 +31,6 @@
#include "../Helpers/x-saherelm.x121.xmas.helper.mq5" #include "../Helpers/x-saherelm.x121.xmas.helper.mq5"
#include "../Helpers/x-saherelm.x121.xpv.helper.mq5" #include "../Helpers/x-saherelm.x121.xpv.helper.mq5"
#include "../Helpers/x-saherelm.x121.xstr.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" #include "../Helpers/x-saherelm.x121.xvwap.helper.mq5"
// //
@@ -51,7 +50,6 @@ struct X121Inputs
X121XDONInputs xdonInputs; X121XDONInputs xdonInputs;
X121X3MAInputs x3maInputs; X121X3MAInputs x3maInputs;
X121XVWAPInputs xvwapInputs; X121XVWAPInputs xvwapInputs;
X121XTRENDInputs xtrendInputs;
// //
// Constructor ... // Constructor ...
@@ -78,7 +76,6 @@ struct X121Inputs
xcheInputs.Clean(); xcheInputs.Clean();
xdonInputs.Clean(); xdonInputs.Clean();
xvwapInputs.Clean(); xvwapInputs.Clean();
xtrendInputs.Clean();
// //
ZeroMemory(this); ZeroMemory(this);
@@ -100,7 +97,6 @@ struct X121Inputs
xdonInputs.Default(); xdonInputs.Default();
x3maInputs.Default(); x3maInputs.Default();
xvwapInputs.Default(); xvwapInputs.Default();
xtrendInputs.Default();
} }
/** /**
@@ -124,8 +120,7 @@ struct X121Inputs
xstrInputs.IsValid() && xstrInputs.IsValid() &&
xcheInputs.IsValid() && xcheInputs.IsValid() &&
xdonInputs.IsValid() && xdonInputs.IsValid() &&
xvwapInputs.IsValid() && xvwapInputs.IsValid()
xtrendInputs.IsValid()
// //
; ;
@@ -152,7 +147,6 @@ struct X121Inputs
int xcheMax = xcheInputs.Max(); int xcheMax = xcheInputs.Max();
int xdonMax = xdonInputs.Max(); int xdonMax = xdonInputs.Max();
int xvwapMax = xvwapInputs.Max(); int xvwapMax = xvwapInputs.Max();
int xtrendMax = xtrendInputs.Max();
// //
result = MathMax(xpvMax, xhkMax); result = MathMax(xpvMax, xhkMax);
@@ -162,7 +156,6 @@ struct X121Inputs
result = MathMax(result, xcheMax); result = MathMax(result, xcheMax);
result = MathMax(result, xdonMax); result = MathMax(result, xdonMax);
result = MathMax(result, xvwapMax); result = MathMax(result, xvwapMax);
result = MathMax(result, xtrendMax);
// //
return result; return result;
@@ -2431,7 +2424,6 @@ class XCX121Helper : public XCBase
XCX121XDONHelper *xdonHelper; XCX121XDONHelper *xdonHelper;
XCX121X3MAHelper *x3maHelper; XCX121X3MAHelper *x3maHelper;
XCX121XVWAPHelper *xvwapHelper; XCX121XVWAPHelper *xvwapHelper;
XCX121XTRENDHelper *xtrendHelper;
// //
// Constructors ... // Constructors ...
@@ -2455,7 +2447,6 @@ class XCX121Helper : public XCBase
xcheInputs.Clean(); xcheInputs.Clean();
x3maInputs.Clean(); x3maInputs.Clean();
xvwapInputs.Clean(); xvwapInputs.Clean();
xtrendInputs.Clean();
// //
delete xccHelper; delete xccHelper;
@@ -2468,7 +2459,6 @@ class XCX121Helper : public XCBase
delete xdonHelper; delete xdonHelper;
delete x3maHelper; delete x3maHelper;
delete xvwapHelper; delete xvwapHelper;
delete xtrendHelper;
// //
ZeroMemory(xccHelper); ZeroMemory(xccHelper);
@@ -2481,7 +2471,6 @@ class XCX121Helper : public XCBase
ZeroMemory(xdonHelper); ZeroMemory(xdonHelper);
ZeroMemory(x3maHelper); ZeroMemory(x3maHelper);
ZeroMemory(xvwapHelper); ZeroMemory(xvwapHelper);
ZeroMemory(xtrendHelper);
} }
// //
@@ -2546,7 +2535,6 @@ class XCX121Helper : public XCBase
xdonInputs = inputs.xdonInputs; xdonInputs = inputs.xdonInputs;
x3maInputs = inputs.x3maInputs; x3maInputs = inputs.x3maInputs;
xvwapInputs = inputs.xvwapInputs; xvwapInputs = inputs.xvwapInputs;
xtrendInputs = inputs.xtrendInputs;
// //
// Initial Helpers ... // Initial Helpers ...
@@ -2681,19 +2669,6 @@ class XCX121Helper : public XCBase
return result; return result;
} }
//
// XTREND ...
xtrendHelper = new XCX121XTRENDHelper();
result = xtrendHelper.Init(
symbol,
period,
xtrendInputs //
);
if (!result)
{
return result;
}
// //
if (inputs.showRSI) if (inputs.showRSI)
{ {
@@ -2918,28 +2893,6 @@ class XCX121Helper : public XCBase
return result; 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() void Free()
{ {
@@ -2952,7 +2905,6 @@ class XCX121Helper : public XCBase
xcheHelper.Free(); xcheHelper.Free();
xdonHelper.Free(); xdonHelper.Free();
xvwapHelper.Free(); xvwapHelper.Free();
xtrendHelper.Free();
} }
// //
@@ -3138,19 +3090,6 @@ class XCX121Helper : public XCBase
return result; return result;
} }
//
// XTREND ...
X121XTRENDConditions xtrendConditions;
result = GetTrendConditions(
xtrendConditions,
barIndex,
loopback //
);
if (!result)
{
return result;
}
// //
// Fill Volume Buffer ... // Fill Volume Buffer ...
for (int i = barIndex; i < barIndex + loopback; i++) for (int i = barIndex; i < barIndex + loopback; i++)
@@ -3422,66 +3361,6 @@ class XCX121Helper : public XCBase
conditions.masLowerBuffer // 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 ... // XATR ...
@@ -4594,7 +4473,6 @@ class XCX121Helper : public XCBase
xdonConditions.Clean(); xdonConditions.Clean();
x3maConditions.Clean(); x3maConditions.Clean();
xvwapConditions.Clean(); xvwapConditions.Clean();
xtrendConditions.Clean();
// //
Free(); Free();
@@ -4628,7 +4506,6 @@ class XCX121Helper : public XCBase
X121XCHEInputs xcheInputs; X121XCHEInputs xcheInputs;
X121X3MAInputs x3maInputs; X121X3MAInputs x3maInputs;
X121XVWAPInputs xvwapInputs; X121XVWAPInputs xvwapInputs;
X121XTRENDInputs xtrendInputs;
// //
int mRSIHandler; int mRSIHandler;
+4 -4
View File
@@ -126,22 +126,22 @@ struct X121XPVInputs
{ {
// //
// Short ... // Short ...
scMethod = X_PERIOD_NOTHING; scMethod = X_PERIOD_NONE;
scPeriod = NULL; scPeriod = NULL;
// //
// Medium ... // Medium ...
mcMethod = X_PERIOD_NOTHING; mcMethod = X_PERIOD_NONE;
mcPeriod = NULL; mcPeriod = NULL;
// //
// Long ... // Long ...
lcMethod = X_PERIOD_NOTHING; lcMethod = X_PERIOD_NONE;
lcPeriod = NULL; lcPeriod = NULL;
// //
// Hind ... // Hind ...
hcMethod = X_PERIOD_NOTHING; hcMethod = X_PERIOD_NONE;
hcPeriod = NULL; hcPeriod = NULL;
// //
+197
View File
@@ -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
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
+3 -3
View File
@@ -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; 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); double mEntry = GetExit(this.symbol, mType);
// //
@@ -1615,7 +1615,7 @@ struct XSignal
bool result = false; bool result = false;
// //
ENUM_POSITION_TYPE mType = GetOpposit(source.type); ENUM_POSITION_TYPE mType = Opposit(source.type);
double mEntry = GetEntry(source.symbol, mType); double mEntry = GetEntry(source.symbol, mType);
// //
File diff suppressed because it is too large Load Diff
@@ -1159,7 +1159,13 @@ struct X121SMCStrategySignalProviderData
// Prepare all ... // Prepare all ...
bool Prepare( bool Prepare(
int barIndex = 0, 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 ... // Trigger ...
result = triggerCycleHelper.GetConditions( if (trigger)
triggerCycleEvents,
triggerPoiEvents,
triggerConditions,
barIndex,
loopback //
);
if (!result)
{ {
// //
Clean(triggerPoiEvents); result = triggerCycleHelper.GetConditions(
Clean(triggerCycleEvents); triggerCycleEvents,
triggerPoiEvents,
triggerConditions,
barIndex,
loopback //
);
if (!result)
{
//
Clean(triggerPoiEvents);
Clean(triggerCycleEvents);
// //
triggerConditions.Clean(); triggerConditions.Clean();
// //
return result; return result;
}
} }
// //
// Decision ... // Decision ...
result = decisionCycleHelper.GetConditions( if (decision)
decisionCycleEvents,
decisionPoiEvents,
decisionConditions,
barIndex,
loopback //
);
if (!result)
{ {
// //
Clean(triggerPoiEvents); result = decisionCycleHelper.GetConditions(
Clean(decisionPoiEvents); decisionCycleEvents,
Clean(triggerCycleEvents); decisionPoiEvents,
triggerConditions.Clean(); decisionConditions,
Clean(decisionCycleEvents); barIndex,
decisionConditions.Clean(); loopback //
);
if (!result)
{
//
Clean(triggerPoiEvents);
Clean(decisionPoiEvents);
Clean(triggerCycleEvents);
triggerConditions.Clean();
Clean(decisionCycleEvents);
decisionConditions.Clean();
// //
return result; return result;
}
} }
// //
// Analyse ... // Analyse ...
result = analyseCycleHelper.GetConditions( if (analyse)
analyseCycleEvents,
analysePoiEvents,
analyseConditions,
barIndex,
loopback //
);
if (!result)
{ {
// //
Clean(triggerPoiEvents); result = analyseCycleHelper.GetConditions(
Clean(analysePoiEvents); analyseCycleEvents,
Clean(decisionPoiEvents); analysePoiEvents,
Clean(triggerCycleEvents); analyseConditions,
Clean(analyseCycleEvents); barIndex,
triggerConditions.Clean(); loopback //
analyseConditions.Clean(); );
Clean(decisionCycleEvents); if (!result)
decisionConditions.Clean(); {
//
Clean(triggerPoiEvents);
Clean(analysePoiEvents);
Clean(decisionPoiEvents);
Clean(triggerCycleEvents);
Clean(analyseCycleEvents);
triggerConditions.Clean();
analyseConditions.Clean();
Clean(decisionCycleEvents);
decisionConditions.Clean();
// //
return result; return result;
}
} }
// //
// Verification ... // Verification ...
result = verificationCycleHelper.GetConditions( if (verification)
verificationCycleEvents,
verificationPoiEvents,
verificationConditions,
barIndex,
loopback //
);
if (!result)
{ {
// //
Clean(triggerPoiEvents); result = verificationCycleHelper.GetConditions(
Clean(analysePoiEvents); verificationCycleEvents,
Clean(decisionPoiEvents); verificationPoiEvents,
Clean(triggerCycleEvents); verificationConditions,
Clean(analyseCycleEvents); barIndex,
triggerConditions.Clean(); loopback //
analyseConditions.Clean(); );
Clean(decisionCycleEvents); if (!result)
decisionConditions.Clean(); {
Clean(verificationPoiEvents); //
Clean(verificationCycleEvents); Clean(triggerPoiEvents);
verificationConditions.Clean(); 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 ... // Consolidation ...
result = consolidationCycleHelper.GetConditions( if (consolidation)
consolidationCycleEvents,
consolidationPoiEvents,
consolidationConditions,
barIndex,
loopback //
);
if (!result)
{ {
// //
Clean(triggerPoiEvents); result = consolidationCycleHelper.GetConditions(
Clean(analysePoiEvents); consolidationCycleEvents,
Clean(decisionPoiEvents); consolidationPoiEvents,
Clean(triggerCycleEvents); consolidationConditions,
Clean(analyseCycleEvents); barIndex,
triggerConditions.Clean(); loopback //
analyseConditions.Clean(); );
Clean(decisionCycleEvents); if (!result)
decisionConditions.Clean(); {
Clean(verificationPoiEvents); //
Clean(consolidationPoiEvents); Clean(triggerPoiEvents);
Clean(verificationCycleEvents); Clean(analysePoiEvents);
verificationConditions.Clean(); Clean(decisionPoiEvents);
Clean(consolidationCycleEvents); Clean(triggerCycleEvents);
consolidationConditions.Clean(); 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 ... // Vision ...
result = visionCycleHelper.GetConditions( if (vision)
visionCycleEvents,
visionPoiEvents,
visionConditions,
barIndex,
loopback //
);
if (!result)
{ {
// result = visionCycleHelper.GetConditions(
Clean(visionPoiEvents); visionCycleEvents,
Clean(triggerPoiEvents); visionPoiEvents,
Clean(analysePoiEvents); visionConditions,
Clean(visionCycleEvents); barIndex,
visionConditions.Clean(); loopback //
Clean(decisionPoiEvents); );
Clean(triggerCycleEvents); if (!result)
Clean(analyseCycleEvents); {
triggerConditions.Clean(); //
analyseConditions.Clean(); Clean(visionPoiEvents);
Clean(decisionCycleEvents); Clean(triggerPoiEvents);
decisionConditions.Clean(); Clean(analysePoiEvents);
Clean(verificationPoiEvents); Clean(visionCycleEvents);
Clean(consolidationPoiEvents); visionConditions.Clean();
Clean(verificationCycleEvents); Clean(decisionPoiEvents);
verificationConditions.Clean(); Clean(triggerCycleEvents);
Clean(consolidationCycleEvents); Clean(analyseCycleEvents);
consolidationConditions.Clean(); 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; return result;
} }
//
// //
// Detecting Signal Conditions ... // Detecting Signal Conditions ...
@@ -2602,21 +2630,16 @@ struct X121SMCStrategyConditionParser
isBullish = isBullish =
// //
// Base Condition ... // Base Condition ...
cXConditions.isSMHKSwitchedToBullish &&
( (
// //
// Validate CBar ... cXConditions.supportsBuffer[cIDX] == cXConditions.valesBuffer[zIDX]
cBar.IsBullish() &&
// //
(cBar.low >= cXConditions.valesGoldenBuffer[cIDX] || // cXConditions.isSarSwitchedToBullish &&
(cBar.low < cXConditions.valesGoldenBuffer[cIDX] && // cXConditions.isSMHKSwitchedToBullish &&
cXConditions.isSarSwitchedToBullish)) && // cBar.low < cXConditions.masLowerBuffer[cIDX] &&
// // cBar.low < cXConditions.valesGoldenBuffer[cIDX] &&
(cBar.open == cXConditions.xhkSMOpenBuffer[cIDX] || // zBar.close < cXConditions.valesGoldenBuffer[cIDX] &&
(cBar.low < cXConditions.xhkSMLowBuffer[cIDX] && // cXConditions.xhkSMCloseBuffer[cIDX] < cXConditions.valesGoldenBuffer[cIDX]
cBar.GetDown() > cXConditions.xhkSMHighBuffer[cIDX])) &&
//
cXConditions.isSarBullish
// //
) )
// //
@@ -2627,21 +2650,9 @@ struct X121SMCStrategyConditionParser
isBearish = isBearish =
// //
// Base Condition ... // Base Condition ...
cXConditions.isSMHKSwitchedToBearish &&
( (
// //
// Validate CBar ... false
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
// //
) )
// //
@@ -117,7 +117,13 @@ class XCX121SMCXWZSignalDetector : public XCBase
// Cycles Conditions ... // Cycles Conditions ...
result = provider.Prepare( result = provider.Prepare(
zIndex, zIndex,
loopback // loopback,
false, // Trigger ...
true, // Decision ...
true, // Analyse ...
true, // Verification ...
true, // Consolidation ...
true // Vision ...
); );
if (!result) if (!result)
{ {
@@ -1002,7 +1002,7 @@ struct X121SMCStrategyXWZWorkingZone
// --------------------------------------------- // ---------------------------------------------
// XPVHK Conditions ... // XPVHK Conditions ...
// --------------------------------------------- // ---------------------------------------------
bool useSenario1 = false; bool useSenario1 = true;
bool isSenario1Happend = false; bool isSenario1Happend = false;
bool isSenario1Bullish = false; bool isSenario1Bullish = false;
bool isSenario1Bearish = false; bool isSenario1Bearish = false;
@@ -784,12 +784,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// XCC ... // XCC ...
x121Inputs.xccInputs.showCandles = showAll || true; x121Inputs.xccInputs.showCandles = showAll || true;
//
// XTREND ...
x121Inputs.xtrendInputs.showUpTrend = showAll || false;
x121Inputs.xtrendInputs.showDownTrend = showAll || false;
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || false;
// //
// XPV ... // XPV ...
x121Inputs.xpvInputs.showSar = showAll || true; x121Inputs.xpvInputs.showSar = showAll || true;