This commit is contained in:
2025-09-16 10:55:50 +03:30
parent 5dd58eec74
commit 83ef415ca2
5 changed files with 1530 additions and 4 deletions
+180 -2
View File
@@ -24,6 +24,7 @@
//
// Imports ...
#include "../Classes/x-saherelm.x-backtester.expert.class.mq5"
#include "../Classes/x-saherelm.x-market.pattern.class.mq5"
#include "../Helpers/x-saherelm.xom1.helper.mq5"
//
@@ -120,8 +121,12 @@ input int valeArrowCode = 159; // Vales Arrow Code
// Define Local Variables ...
//
string eaLogTag; // EA Log Prefix ...
XCBackTesterEA *eaExpert; // EA Expert ...
string eaLogTag; // EA Log Prefix ...
XCBackTesterEA *eaExpert; // EA Expert ...
XCMarketPatternDetector *eaPatternDetector; // EA Pattern Detector ...
//
XBarTracker eaBarTracker; // EA Bar Traker ...
//
int eaHandler = INVALID_HANDLE; // Indicator Handler ...
@@ -284,6 +289,23 @@ int OnInit()
return INIT_FAILED;
}
//
// Initialize Bar Tracker ...
isInited = eaBarTracker.Init(
_Symbol,
_Period //
);
if (!isInited)
{
//
Print(ShortName, ": Initialization Failed ...");
return INIT_FAILED;
}
//
// Instantiate Market Pattern Detector ...
eaPatternDetector = new XCMarketPatternDetector();
//
Print(ShortName, ": Initialized Successfully ...");
return INIT_SUCCEEDED;
@@ -313,6 +335,13 @@ void OnDeinit(const int reason)
// De Init Indicator ...
IndicatorRelease(eaHandler);
//
eaBarTracker.Clean();
//
delete eaPatternDetector;
ZeroMemory(eaPatternDetector);
//
delete eaExpert;
ZeroMemory(eaExpert);
@@ -322,7 +351,156 @@ void OnDeinit(const int reason)
// On Tick Handler ...
void OnTick()
{
//
eaExpert.HandleOnTick();
//
bool isNewBar = eaBarTracker.IsNewBar();
if (isNewBar)
{
//
// Initialize 1 Indexed Bar ...
XOHCL cBar;
bool has = cBar.Init(
_Symbol,
_Period,
1 //
);
if (has)
{
//
// Do Analysis ...
//
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
//
// Checking Momentum Bar ...
bool isMomentum = eaPatternDetector.IsMomentumBar(
cBar,
iDir //
);
bool isBullishMomentum = isMomentum &&
IsSpecifiedBullish(iDir);
bool isBearishMomentum = isMomentum &&
IsSpecifiedBearish(iDir);
if (isMomentum)
{
Print(ToXString(iDir), " Momentum Bar: ", cBar.time);
}
//
// Checking Engulfed Bar ...
bool isEngulfed = eaPatternDetector.IsEngulfedBar(
cBar,
iDir //
);
bool isBullishEngulfed = isEngulfed &&
IsSpecifiedBullish(iDir);
bool isBearishEngulfed = isEngulfed &&
IsSpecifiedBearish(iDir);
if (isEngulfed)
{
Print(ToXString(iDir), " Engulfed Bar: ", cBar.time);
}
//
// Checking TruGaped Bar ...
bool isTrueGaped = eaPatternDetector.IsTrueGapedBar(
cBar,
iDir //
);
bool isBullishTrueGaped = isTrueGaped &&
IsSpecifiedBullish(iDir);
bool isBearishTrueGaped = isTrueGaped &&
IsSpecifiedBearish(iDir);
if (isTrueGaped)
{
Print(ToXString(iDir), " TrueGapped Bar: ", cBar.time);
}
//
// Checking Pinned Bar ...
bool isPinned = eaPatternDetector.IsPinnedBar(
cBar,
iDir //
);
bool isBullishPinned = isPinned &&
IsSpecifiedBullish(iDir);
bool isBearishPinned = isPinned &&
IsSpecifiedBearish(iDir);
if (isPinned)
{
Print(ToXString(iDir), " Pinned Bar: ", cBar.time);
}
//
// Checking Star Pattern ...
bool isStarPattern = eaPatternDetector.IsStartPattern(
cBar,
iDir //
);
bool isBullishStarPattern = isStarPattern &&
IsSpecifiedBullish(iDir);
bool isBearishStarPattern = isStarPattern &&
IsSpecifiedBearish(iDir);
if (isStarPattern)
{
Print(ToXString(iDir), " Star Pattern: ", cBar.time);
}
//
// Checking Piercing Pattern ...
bool isPiercingPattern = eaPatternDetector.IsPiercingPattern(
cBar,
iDir //
);
bool isBullishPiercingPattern = isPiercingPattern &&
IsSpecifiedBullish(iDir);
bool isBearishPiercingPattern = isPiercingPattern &&
IsSpecifiedBearish(iDir);
if (isPiercingPattern)
{
Print(ToXString(iDir), " Piercing Pattern: ", cBar.time);
}
//
// Checking Rising Pattern ...
bool isRisingPattern = eaPatternDetector.IsRisingPattern(
cBar,
iDir //
);
bool isBullishRisingPattern = isRisingPattern &&
IsSpecifiedBullish(iDir);
bool isBearishRisingPattern = isRisingPattern &&
IsSpecifiedBearish(iDir);
if (isRisingPattern)
{
Print(ToXString(iDir), " Rising Pattern: ", cBar.time);
}
//
// Checking Flag Pattern ...
XOHCL swingBar;
bool isFlagPattern = eaPatternDetector.IsFlagPattern(
cBar,
iDir,
swingBar //
);
bool isBullishFlagPattern = isFlagPattern &&
IsSpecifiedBullish(iDir);
bool isBearishFlagPattern = isFlagPattern &&
IsSpecifiedBearish(iDir);
if (isFlagPattern)
{
Print(ToXString(iDir), " Flag Pattern: ", cBar.time, ", Swing: ", swingBar.time);
}
swingBar.Clean();
}
//
cBar.Clean();
}
}
//