last ...
This commit is contained in:
+1062
-691
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,33 @@
|
||||
{
|
||||
"id": "6f8db3d6-fcaa-4522-bee5-0e3e38c96e73",
|
||||
"title": "Doing",
|
||||
"cards": []
|
||||
"cards": [
|
||||
{
|
||||
"id": "f8eb6951-f337-40da-9b98-e468f77709fd",
|
||||
"listId": "6f8db3d6-fcaa-4522-bee5-0e3e38c96e73",
|
||||
"title": "implementing Signallers Has Strategy Functions ...",
|
||||
"description": "Fill Signal Strategies\n",
|
||||
"labels": [],
|
||||
"checkboxes": [
|
||||
{
|
||||
"id": "832b1c6e-8219-48ed-a897-45251f444cb1",
|
||||
"title": "Strategy 1",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"id": "ca4683e7-14f0-4dde-86a2-16ea71e08a48",
|
||||
"title": "Add more Validations on Entries in Strategy 1;",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"id": "bd3c09a7-1fbf-45f9-bcf7-ec0f71d1be24",
|
||||
"title": "adding support Validate by Support and Resistances Zones; on Strategy 1; ",
|
||||
"checked": false
|
||||
}
|
||||
],
|
||||
"comments": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c6b07a7f-d2e7-4f67-a5a9-0d93cd8bf981",
|
||||
|
||||
@@ -4688,7 +4688,8 @@ bool IsProviderFilterPassed(
|
||||
//
|
||||
return !IsValid(provider)
|
||||
? true
|
||||
: provider == item.provider;
|
||||
: provider == item.provider ||
|
||||
Contains(provider, item.provider);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -438,7 +438,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -448,8 +447,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsPinnedBar(bar, dir) &&
|
||||
IsXBullish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -477,7 +478,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -487,8 +487,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsPinnedBar(bar, dir) &&
|
||||
IsXBearish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -550,7 +552,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -560,8 +561,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsMomentumBar(bar, dir) &&
|
||||
IsXBullish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BULLISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -588,7 +591,6 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
// Add candlestick confirmation ...
|
||||
XOHCL bar;
|
||||
ENUM_X_DIRECTION dir;
|
||||
result = result &&
|
||||
bar.Init(symbol, period, barIndex);
|
||||
if (!result)
|
||||
@@ -598,8 +600,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
|
||||
//
|
||||
result = result &&
|
||||
IsMomentumBar(bar, dir) &&
|
||||
IsXBearish(dir);
|
||||
HasCandlestickDirection(
|
||||
bar,
|
||||
X_DIRECTION_BEARISH //
|
||||
);
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
@@ -1208,6 +1212,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
int loopback = 50,
|
||||
bool forceValidation = true,
|
||||
int validationLength = 7,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
string forSymbol = NULL,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
@@ -1284,6 +1291,8 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
tmpValue = tmpBar.FindLowest(validationLength, MODE_LOW);
|
||||
has = NotEmptyZero(tmpValue) &&
|
||||
tmpValue == tmpBar.low;
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
@@ -1325,7 +1334,14 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
// Validate ...
|
||||
if (HasChild(zones) && forceValidation)
|
||||
{
|
||||
ValidateZones(zones, barIndex);
|
||||
//
|
||||
ValidateZones(
|
||||
zones,
|
||||
barIndex,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1341,6 +1357,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
int loopback = 50,
|
||||
bool forceValidation = true,
|
||||
int validationLength = 7,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
string forSymbol = NULL,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
@@ -1458,7 +1477,14 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
// Validate ...
|
||||
if (HasChild(zones) && forceValidation)
|
||||
{
|
||||
ValidateZones(zones, barIndex);
|
||||
//
|
||||
ValidateZones(
|
||||
zones,
|
||||
barIndex,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1471,6 +1497,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
void ValidateZones(
|
||||
XBoxZone &zones[],
|
||||
int barIndex = 0,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100,
|
||||
ENUM_X_BOUNDARY_PRICE forPriceType = X_BOUNDARY_PRICE_UP_DOWN //
|
||||
)
|
||||
{
|
||||
@@ -1478,9 +1507,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
barIndex = kiParser.NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validation ...
|
||||
has = HasChild(zones) &&
|
||||
IsXValid(forPriceType);
|
||||
if (!has)
|
||||
@@ -1488,6 +1515,13 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalizetion ...
|
||||
barIndex = kiParser.NormalizeBarIndex(barIndex);
|
||||
minimumRetests = NormalizeInt(minimumRetests, 0);
|
||||
retestLoopback = NormalizeInt(retestLoopback, 50);
|
||||
retestThreshold = NormalizeDouble(retestThreshold, 5, 10);
|
||||
|
||||
//
|
||||
XOHCL tmpBar;
|
||||
XBoxZone tmp;
|
||||
@@ -1498,6 +1532,17 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
//
|
||||
tmp = zones[i];
|
||||
|
||||
//
|
||||
if (minimumRetests > 0)
|
||||
{
|
||||
//
|
||||
int retests = CounteZoneTouches(tmp, retestThreshold, retestLoopback);
|
||||
if (retests < minimumRetests)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Zone ...
|
||||
has = false;
|
||||
@@ -1575,7 +1620,10 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
ENUM_TIMEFRAMES forPeriod = NULL,
|
||||
int loopback = 50,
|
||||
int minorValidation = 7,
|
||||
int majorValidation = 14 //
|
||||
int majorValidation = 14,
|
||||
int minimumRetests = 2,
|
||||
double retestThreshold = 10,
|
||||
int retestLoopback = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1618,6 +1666,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
minorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1644,6 +1695,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
minorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1677,6 +1731,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
majorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1703,6 +1760,9 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
loopback,
|
||||
true, // Force Validation ...
|
||||
majorValidation,
|
||||
minimumRetests,
|
||||
retestThreshold,
|
||||
retestLoopback,
|
||||
forSymbol,
|
||||
forPeriod //
|
||||
);
|
||||
@@ -1726,6 +1786,121 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
|
||||
XClean(tmpSupports);
|
||||
XClean(tmpResistances);
|
||||
}
|
||||
|
||||
int CounteZoneTouches(
|
||||
XBoxZone &zone,
|
||||
double threshold = 10,
|
||||
int loopback = 100 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
loopback = NormalizeInt(loopback, 50);
|
||||
threshold = NormalizeDouble(threshold, 10);
|
||||
|
||||
//
|
||||
if (!zone.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpBar;
|
||||
int start = zone.ToIndex();
|
||||
bool isUpperTouched = false;
|
||||
bool isLowerTouched = false;
|
||||
double points = GetPoints(zone.symbol);
|
||||
double distance = points * threshold;
|
||||
int end = MathMin(start + loopback, zone.FromIndex());
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
if (tmpBar.Init(zone.symbol, zone.period, i))
|
||||
{
|
||||
//
|
||||
isUpperTouched = MathAbs(tmpBar.high - zone.upper) <= distance;
|
||||
isLowerTouched = MathAbs(tmpBar.low - zone.lower) <= distance;
|
||||
|
||||
//
|
||||
if (
|
||||
(zone.IsBullish() &&
|
||||
(isLowerTouched ||
|
||||
MathAbs(tmpBar.close - zone.lower) <= distance)) ||
|
||||
(zone.IsBearish() &&
|
||||
(isUpperTouched ||
|
||||
MathAbs(tmpBar.close - zone.upper) <= distance)))
|
||||
{
|
||||
//
|
||||
result++;
|
||||
Add(
|
||||
tmpBar.time,
|
||||
zone.tests //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
tmpBar.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
tmpBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasNearZone(
|
||||
int &index,
|
||||
double price,
|
||||
double threshold,
|
||||
XBoxZone &zones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = HasChild(zones) &&
|
||||
NotEmptyZero(price) &&
|
||||
NotEmptyZero(threshold) &&
|
||||
price > 0 &&
|
||||
threshold > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double points = GetPoints(zones[0].symbol);
|
||||
double distance = points * threshold;
|
||||
for (int i = 0; i < ArraySize(zones); i++)
|
||||
{
|
||||
//
|
||||
// Check Price Distance by Upper ...
|
||||
result = price >= zones[i].lower - distance &&
|
||||
price <= zones[i].upper + distance;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Library
|
||||
// -------------------------------------------------
|
||||
// Name: XCX121XKIEALib ...
|
||||
// Description: X121XKI Library ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm X121XKIEA Library"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// Enums ...
|
||||
|
||||
// #region XKIStrategies ...
|
||||
enum X121XKIStrategies
|
||||
{
|
||||
X121_XKI_STRATEGY_UNKNOWN = 0,
|
||||
X121_XKI_STRATEGY_1 = 1,
|
||||
X121_XKI_STRATEGY_2 = 2,
|
||||
X121_XKI_STRATEGY_3 = 3,
|
||||
X121_XKI_STRATEGY_4 = 4,
|
||||
X121_XKI_STRATEGY_5 = 5,
|
||||
X121_XKI_STRATEGY_6 = 6,
|
||||
};
|
||||
bool IsXValid(X121XKIStrategies value)
|
||||
{
|
||||
return value != X121_XKI_STRATEGY_UNKNOWN;
|
||||
}
|
||||
string ToXString(X121XKIStrategies value)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (IsXValid(value))
|
||||
{
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case X121_XKI_STRATEGY_1:
|
||||
result = "1";
|
||||
break;
|
||||
//
|
||||
case X121_XKI_STRATEGY_2:
|
||||
result = "2";
|
||||
break;
|
||||
//
|
||||
case X121_XKI_STRATEGY_3:
|
||||
result = "3";
|
||||
break;
|
||||
//
|
||||
case X121_XKI_STRATEGY_4:
|
||||
result = "4";
|
||||
break;
|
||||
//
|
||||
case X121_XKI_STRATEGY_5:
|
||||
result = "5";
|
||||
break;
|
||||
//
|
||||
case X121_XKI_STRATEGY_6:
|
||||
result = "6";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
X121XKIStrategies ToX121XKIStrategy(string value)
|
||||
{
|
||||
//
|
||||
X121XKIStrategies result = X121_XKI_STRATEGY_UNKNOWN;
|
||||
|
||||
//
|
||||
if (IsXValid(value))
|
||||
{
|
||||
//
|
||||
if (value == ToXString(X121_XKI_STRATEGY_1))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_1;
|
||||
}
|
||||
else if (value == ToXString(X121_XKI_STRATEGY_2))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_2;
|
||||
}
|
||||
else if (value == ToXString(X121_XKI_STRATEGY_3))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_3;
|
||||
}
|
||||
else if (value == ToXString(X121_XKI_STRATEGY_4))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_4;
|
||||
}
|
||||
else if (value == ToXString(X121_XKI_STRATEGY_5))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_5;
|
||||
}
|
||||
else if (value == ToXString(X121_XKI_STRATEGY_6))
|
||||
{
|
||||
result = X121_XKI_STRATEGY_6;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
Reference in New Issue
Block a user