refactor all requirements for draw and detect pois and also add Fima Helper, Parser Class Implementations for Separation of Concerns ...

This commit is contained in:
2025-10-24 05:03:31 +03:30
parent d63c5596fc
commit 0b0cd70049
21 changed files with 25191 additions and 8447 deletions
File diff suppressed because it is too large Load Diff
@@ -24,6 +24,7 @@
// Imports ...
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
#include "../Classes/x-saherelm.xfima.x-poi.detector.class.mq5"
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
@@ -45,6 +46,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
XCXFIMAHelperParser *fimaParser; // XFIMA Helper Parser ...
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ...
@@ -92,9 +94,13 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
}
}
//
// Instantiate XFIMA Helper Parser ...
fimaParser = new XCXFIMAHelperParser(fimaHelper);
//
poiDrawer = new XCXFIMAPOIDrawer();
poiDetector = new XCXFIMAPOIDetector(fimaHelper);
poiDetector = new XCXFIMAPOIDetector(fimaHelper, fimaParser);
//
// Configure ...
@@ -556,25 +562,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// Draw Flags ...
bool draw = true;
bool drawZone = true;
bool drawOrderFlow = true;
bool drawMarketStructurePivots = true;
bool drawMarketStructureAnalysis = true;
bool drawMarketStructureOrderFlow = true;
XPOIDrawConfig iDrawConfig;
//
// Signal Checking ...
//
// Detecting OrderFlow ...
XBoxZone orderFlow[];
ENUM_X_DIRECTION orderFlowDir;
bool hasOrderFlow = poiDetector.HasOrderFlow(
bar,
orderFlowDir,
orderFlow,
2,
false, // Contains OB ...
true, // Contains FVG ...
false // Contains Support and Resistances ...
);
// Analyse Market Strucutre ...
XFIMAMarketStructure marketStructure;
//
// Signaller 1 ...
@@ -660,14 +658,24 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
if (result && validateByOrderFlow)
{
//
bool isBullish = hasOrderFlow &&
IsXBullish(dir) &&
IsXBullish(orderFlowDir);
// Analyse Market Structure if Required ...
if (!marketStructure.IsValid())
{
//
poiDetector.AnalyseMarket(
marketStructure,
structureConfig,
bar.Index() //
);
}
//
bool isBearish = hasOrderFlow &&
IsXBearish(dir) &&
IsXBearish(orderFlowDir);
bool isBullish = IsXBullish(dir) &&
marketStructure.HasBullishOrderFlow();
//
bool isBearish = IsXBearish(dir) &&
marketStructure.HasBearishOrderFlow();
//
// Summarizing result ...
@@ -749,7 +757,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
// Partial Close on TP 1 ...
if (hasPartialCloseOnTp1 && tp > tp1)
if (hasPartialCloseOnTp1)
{
//
iTarget.Clean();
@@ -814,10 +822,52 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Draw Order Flow ...
if (drawOrderFlow && HasChild(orderFlow))
// Draw Market Structure ...
//
// Analyse Market Structure if Required ...
if (!marketStructure.IsValid())
{
poiDrawer.DrawZones(orderFlow, iDrawConfig);
//
poiDetector.AnalyseMarket(
marketStructure,
structureConfig,
bar.Index() //
);
}
if (marketStructure.IsValid())
{
//
// Order Flow ...
if (drawMarketStructureOrderFlow && marketStructure.HasOrderFlow())
{
poiDrawer.DrawZones(marketStructure.orderFlow, iDrawConfig);
}
//
// Pivots ...
if (drawMarketStructurePivots)
{
//
XPivot pivots[];
int pivotsCount = marketStructure.CollectPivots(
pivots,
true // Contains Patterns ...
);
if (IsValidSize(pivotsCount))
{
poiDrawer.DrawPivots(pivots, iDrawConfig);
}
//
XClean(pivots);
}
//
// Analysis ...
if (drawMarketStructureAnalysis)
{
//
}
}
//
@@ -841,6 +891,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
DebugBreak();
}
//
// Cleanup ...
iDrawConfig.Clean();
marketStructure.Clean();
//
return result;
}
@@ -918,13 +973,13 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Reading HK Bond ...
// Reading HK Band ...
//
double pHKBondUpper = fimaHelper.GetHKBondUpper(pBar.Index());
double pHKBondLower = fimaHelper.GetHKBondLower(pBar.Index());
int overHKBondUpperCount = fimaHelper.CountOverHKBondUpper(pullBackStartBar, X_PRICE_LOW);
int underHKBondLowerCount = fimaHelper.CountUnderHKBondLower(pullBackStartBar, X_PRICE_HIGH);
double pHKBandUpper = fimaHelper.GetHKBandUpper(pBar.Index());
double pHKBandLower = fimaHelper.GetHKBandLower(pBar.Index());
int overHKBandUpperCount = fimaParser.CountOverHKBandUpper(pullBackStartBar, X_PRICE_LOW);
int underHKBandLowerCount = fimaParser.CountUnderHKBandLower(pullBackStartBar, X_PRICE_HIGH);
//
// Reading PV Requirements ...
@@ -934,10 +989,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
int lastValeUnderLastIDX = -1;
double pPeak = fimaHelper.GetPeak(pBar.Index());
double pVale = fimaHelper.GetVale(pBar.Index());
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index());
int sameVales = fimaHelper.CountSameVales(pBar.Index());
fimaHelper.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
fimaHelper.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
int samePeaks = fimaParser.CountSamePeaks(pBar.Index());
int sameVales = fimaParser.CountSameVales(pBar.Index());
fimaParser.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
fimaParser.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
//
// Reading pBar Patterns ...
@@ -1040,7 +1095,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
hasBullishInside &&
isPullbackBullish &&
isPBarHasBullishPatterns &&
fimaHelper.IsSarBullish(pBar.Index()) &&
fimaParser.IsSARBullish(pBar.Index()) &&
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
pVale <= affectedZonesBullish[insideBullishIDX].upper)
//
@@ -1052,7 +1107,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
hasBearishInside &&
isPullbackBearish &&
isPBarHasBearishPatterns &&
fimaHelper.IsSarBearish(pBar.Index()) &&
fimaParser.IsSARBearish(pBar.Index()) &&
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
//
@@ -1064,24 +1119,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
isBearish;
if (result)
{
//
if (isBullish)
{
//
poiDrawer.DrawZone(
affectedZonesBullish[insideBullishIDX],
structureDrawConfig.drawConfig //
);
}
else
{
//
poiDrawer.DrawZone(
affectedZonesBearish[insideBearishIDX],
structureDrawConfig.drawConfig //
);
}
//
dir =
isBullish
@@ -1238,10 +1275,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
double pVale = fimaHelper.GetVale(pBar.Index());
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
bool isPPeakOverLast = fimaParser.IsPeakOverLast(pBar.Index());
bool isPValeUnderLast = fimaParser.IsValeUnderLast(pBar.Index());
bool isP2PeakOverLast = fimaParser.IsPeakOverLast(p2Bar.Index());
bool isP2ValeUnderLast = fimaParser.IsValeUnderLast(p2Bar.Index());
bool isPeakOverLast = isPPeakOverLast ||
isP2PeakOverLast;
bool isValeUnderLast = isPValeUnderLast ||
@@ -1473,7 +1510,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
// XFIMA Consolidation ...
//
bool isConsolidation = fimaHelper.HasPVConsolidationZone(
bool isConsolidation = poiDetector.DetectPVConsolidationZone(
zone,
pBar.Index(),
true, // Force PV Break ...
@@ -1707,12 +1744,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
result = isBullish ||
isBearish;
if (result)
{
//
poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
Print("OrderFlow Detected ...");
}
//
isBullish =
File diff suppressed because it is too large Load Diff
@@ -702,79 +702,6 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer
}
}
/**
* Draw Specified Market Structure Based on Given Configs ...
*
* @param structure: XFIMAMarketStructure, reference to Provide Specifid Market Structure ...
* @param config: XFIMAMarketStructureDrawerConfig, reference to Provide Drawing Configurations ...
*/
void DrawMarketStructure(
XFIMAMarketStructure &structure,
XFIMAMarketStructureDrawerConfig &config //
)
{
//
// Validate ...
bool has = structure.IsValid();
if (!has)
{
return;
}
//
// PV Analysis ...
if (config.drawPVAnalysis)
{
//
has = structure.pvAnalysis.IsValid();
if (has)
{
//
DrawPivotAnalysis(
structure.pvAnalysis,
config.pivotAnalysisDrawConfig //
);
}
}
//
// ZG Analysis ...
if (config.drawZGAnalysis)
{
//
has = structure.zgAnalysis.IsValid();
if (has)
{
//
DrawPivotAnalysis(
structure.zgAnalysis,
config.pivotAnalysisDrawConfig //
);
}
}
//
// Bars Analysis ...
if (config.drawBarsAnalysis)
{
//
int count = ArraySize(structure.barsAnalysis);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
//
DrawPatternAnalysis(
structure.barsAnalysis[i],
config.barAnalysisDrawConfig //
);
}
}
}
}
//
};