This commit is contained in:
2026-01-03 17:28:07 +03:30
parent 1f7bd4404b
commit 163259c717
6 changed files with 1915 additions and 719 deletions
@@ -27,6 +27,7 @@
#include "../Classes/x-saherelm.x121.xki.parser.class.mq5"
#include "../Classes/x-saherelm.x121.xki.x-poi.detector.class.mq5"
#include "../Classes/x-saherelm.x121.xki.x-poi.drawer.class.mq5"
#include "../Libraries/x-saherelm.x121.xki.lib.mq5"
//
// Implementation ...
@@ -380,6 +381,10 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
sl, // Provided Price for SL ...
0 // Specified Risk in Point ....
);
if (has)
{
iSignal.provider += "_" + iZone.type;
}
}
//
@@ -436,6 +441,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
double points10 = 0;
double points50 = 0;
double points100 = 0;
string provider = NULL;
int samePVValidation = 5;
bool isPeakOverLast = false;
bool isValeUnderLast = false;
@@ -449,10 +455,31 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
points100 = 100 * positions[i].GetPointsValue();
//
// Near to TP Guard ...
has = positions[i].profit > 0;
// Check Provided By Strategy 1 ...
provider = positions[i].provider;
StringReplace(
provider,
name,
"" //
);
has = Contains(ToXString(X121_XKI_STRATEGY_1), positions[i].provider);
if (has)
{
//
// Now we Check Exit ...
// if (positions[i].IsLong())
// {
// has = ExitBullishPOILong();
// }
// else if (positions[i].IsShort())
// {
// has = ExitBearishPOIShort();
// }
// //
// if (has)
// {
// }
}
}
@@ -564,7 +591,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller1HasSignal)
{
//
provider += "1";
provider += ToXString(X121_XKI_STRATEGY_1);
//
if (!zone.IsValid())
@@ -597,7 +624,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller2HasSignal)
{
//
provider += "2";
provider += ToXString(X121_XKI_STRATEGY_2);
//
if (!zone.IsValid())
@@ -630,7 +657,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller3HasSignal)
{
//
provider += "3";
provider += ToXString(X121_XKI_STRATEGY_3);
//
if (!zone.IsValid())
@@ -663,7 +690,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller4HasSignal)
{
//
provider += "4";
provider += ToXString(X121_XKI_STRATEGY_4);
//
if (!zone.IsValid())
@@ -696,7 +723,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller5HasSignal)
{
//
provider += "5";
provider += ToXString(X121_XKI_STRATEGY_5);
//
if (!zone.IsValid())
@@ -729,7 +756,7 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
if (signaller6HasSignal)
{
//
provider += "6";
provider += ToXString(X121_XKI_STRATEGY_6);
//
if (!zone.IsValid())
@@ -870,6 +897,10 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
// Summarize Result ...
result = zone.IsValid() &&
HasDirection(dir);
if (result)
{
zone.type = "" + provider;
}
//
// Cleanup ...
@@ -944,6 +975,314 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = IsBullishPOILongEntry(barIndex);
bool isBearish = IsBearishPOIShortEntry(barIndex);
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
XOHCL iBar;
result = iBar.Init(bar.symbol, bar.period, barIndex);
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Validate near Support / Resistance Zones ...
bool validateNearSupRes = true;
if (result && validateNearSupRes)
{
//
// Configs ...
int loopback = 100;
int validationLength = 7;
double nearThreshold = 5;
int validationRetests = 0;
int validationLoopback = 100;
double validationThreshold = 5;
//
// Filling Zones ...
XBoxZone zones[];
if (isBullish)
{
//
// Detect Supports ...
poiDetector.DetectSupports(
zones,
barIndex,
loopback,
true,
validationLength, // Validation Length ...
validationRetests, // Min Retest ...
validationThreshold, // Retest Threshold ...
validationLoopback, // Retest Loopback ...
symbol,
period //
);
}
else if (isBearish)
{
//
// Detect Resistances ...
poiDetector.DetectResistances(
zones,
barIndex,
loopback,
true,
validationLength, // Validation Length ...
validationRetests, // Min Retest ...
validationThreshold, // Retest Threshold ...
validationLoopback, // Retest Loopback ...
symbol,
period //
);
}
//
if (HasChild(zones))
{
//
XPOIDrawConfig iConfig;
iConfig.Default();
//
poiDrawer.DrawZones(zones, iConfig);
iConfig.Clean();
// DebugBreak();
}
//
// Check Has Nearest ...
int nearIDX = -1;
result = poiDetector.HasNearZone(
nearIDX,
bar.close,
nearThreshold,
zones //
);
//
// Validate ...
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
// Validate by ATR Rising/Falling ...
bool validateByATRRaisFalling = true;
if (result && validateByATRRaisFalling)
{
//
// Bullish:
// - ATR Lower Rising ...
// - ATR Over ATR Ma ...
// Bearsih:
// - ATR Upper Falling ...
// - ATR Over ATR Ma ...
//
isBullish =
isBullish &&
// kiHelper.GetATR(barIndex) > kiHelper.GetATRSmoothed(barIndex) &&
kiHelper.GetKILower(barIndex) > kiHelper.GetKILower(barIndex + 1);
isBearish =
isBearish &&
// kiHelper.GetATR(barIndex) > kiHelper.GetATRSmoothed(barIndex) &&
kiHelper.GetKIUpper(barIndex) < kiHelper.GetKIUpper(barIndex + 1);
result = isBullish || isBearish;
//
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
// Validate by RSI ...
bool validatebyRSI = false;
if (result && validatebyRSI)
{
//
// Bullish:
// - Not in Over Baught;
// - Rising;
// Bearish :
// - Not in Over Sold;
// - Falling;
//
isBullish =
isBullish &&
!kiParser.IsRSIOverbought(barIndex) &&
kiHelper.GetRSI(barIndex) > kiHelper.GetRSI(barIndex + 1);
isBearish =
isBearish &&
!kiParser.IsRSIOversold(barIndex) &&
kiHelper.GetRSI(barIndex) < kiHelper.GetRSI(barIndex + 1);
result = isBullish || isBearish;
//
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
// Validate by iBar Pattern ...
// in this Strategy we have PinBar or SignalKeyBar ...
bool validateByBarPatterns = false;
if (result && validateByBarPatterns)
{
//
// Pin ...
bool isPinBar = poiDetector.IsPinnedBar(
iBar,
dir //
);
bool isPinBarBullish =
isPinBar &&
IsXBullish(dir);
bool isPinBarBearish =
isPinBar &&
IsXBearish(dir);
//
// Engulfe ...
bool isEngulfed = poiDetector.IsEngulfedBar(
iBar,
dir //
);
bool isEngulfedBullish =
isEngulfed &&
IsXBullish(dir);
bool isEngulfedBearish =
isEngulfed &&
IsXBearish(dir);
//
// Signal Key Bar ...
bool isSignalKeyBar = poiDetector.IsSignalKeyBarPattern(
iBar,
dir //
);
bool isSignalKeyBarBullish =
isSignalKeyBar &&
IsXBullish(dir);
bool isSignalKeyBarBearish =
isSignalKeyBar &&
IsXBearish(dir);
//
isBullish =
isBullish &&
(isEngulfedBullish);
isBearish =
isBearish &&
(isEngulfedBearish);
// //
// isBullish =
// isBullish &&
// (isPinBarBullish ||
// isEngulfedBullish ||
// isSignalKeyBarBullish);
// isBearish =
// isBearish &&
// (isPinBarBearish ||
// isEngulfedBearish ||
// isSignalKeyBarBearish);
//
result = isBullish || isBearish;
//
if (!result)
{
//
isBullish = false;
isBearish = false;
}
}
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
//
iBar.Clean();
return result;
}
//
// Prepare Zone ...
double entry = GetEntry(iBar.symbol, dir);
if (result)
{
//
double upper = isBullish
? entry
: iBar.high;
double lower = isBullish
? iBar.low
: entry;
datetime to = bar.time;
datetime from = iBar.BeforeOn();
result = zone.Init(
iBar.symbol,
iBar.period,
upper,
lower,
from,
to,
dir,
"XS1" //
);
if (result)
{
//
XPOIDrawConfig iConfig;
iConfig.Default();
//
poiDrawer.DrawZone(zone, iConfig);
//
// DebugBreak();
}
}
//
iBar.Clean();
//
result =
result &&
@@ -985,6 +1324,38 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = false;
bool isBearish = false;
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
return result;
}
//
// Prepare Zone ...
//
result =
result &&
@@ -1026,6 +1397,38 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = false;
bool isBearish = false;
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
return result;
}
//
// Prepare Zone ...
//
result =
result &&
@@ -1067,6 +1470,38 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = false;
bool isBearish = false;
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
return result;
}
//
// Prepare Zone ...
//
result =
result &&
@@ -1108,6 +1543,38 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = false;
bool isBearish = false;
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
return result;
}
//
// Prepare Zone ...
//
result =
result &&
@@ -1149,6 +1616,38 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
//
int barIndex = bar.Index() + 1;
//
// Retrieve Base Conditions ...
bool isBullish = false;
bool isBearish = false;
//
// Validate Conditions ...
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
// Do Validation and Filtering Market Structure if required ...
//
// Check and Prepare Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish ? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(dir);
if (!result)
{
return result;
}
//
// Prepare Zone ...
//
result =
result &&