From e2b05b645552fcb7ccee4a55aaa3af79dc4cce96 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 24 Sep 2025 14:32:49 +0330 Subject: [PATCH] well tested truge detecting ... --- Classes/x-saherelm.x-poi.drawer.class.mq5 | 6 +- Experts/x-saherelm.xfima.backtester.ea.mq5 | 29 +- .../x-saherelm.xfima.x-poi.drawer.class.mq5 | 632 +++++++++++++++++- XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 | 75 +++ 4 files changed, 736 insertions(+), 6 deletions(-) diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index 37ac9611..0ffbe495 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -285,7 +285,7 @@ class XCPOIDrawer : public XCBase (IsValid(prefix) ? prefix + "_" : prefix) + - barTag; + ToMD5(barTag); // object = new XCBarArrowObject(); @@ -784,6 +784,10 @@ class XCPOIDrawer : public XCBase // bool result = false; + // + // Prepare ... + object = NULL; + // int count = ArraySize(swings); result = HasChild(swings) && diff --git a/Experts/x-saherelm.xfima.backtester.ea.mq5 b/Experts/x-saherelm.xfima.backtester.ea.mq5 index 41341b59..122eda11 100644 --- a/Experts/x-saherelm.xfima.backtester.ea.mq5 +++ b/Experts/x-saherelm.xfima.backtester.ea.mq5 @@ -147,8 +147,9 @@ XCXFIMAStrategy1Signaller *fima1Signaller; // XFIMA1 Signaller ... XCXFIMAStrategy2Signaller *fima2Signaller; // XFIMA2 Signaller ... // -XFIMAMarketStructure marketStructure; // POI Analysis Result ... -XFIMAPatternDetectorConfig detectorConfig; // POI Detector Config ... +XFIMAMarketStructure marketStructure; // POI Analysis Result ... +XFIMAPatternDetectorConfig detectorConfig; // POI Detector Config ... +XFIMAMarketStructureDrawerConfig marketStructureDrawerConfig; // POI Drawer Config ... // // Drawer and eaDraws ... @@ -383,8 +384,10 @@ int OnInit() } // - // Configure XFIMA POI Detector ... - detectorConfig.Default(); + // Configure XFIMA POI Detector / Drawer ... + detectorConfig.Clean(); + detectorConfig.detectTrueGaped = true; + marketStructureDrawerConfig.FullDraw(); // Print(ShortName, ": Initialized Successfully ..."); @@ -469,6 +472,24 @@ void OnTick() marketStructure, detectorConfig // ); + CArrayObj *iObjects; + int drawnsCount = fima2Signaller.poiDrawer.DrawMarketStructure( + marketStructure, + marketStructureDrawerConfig, + iObjects // + ); + if (IsValidSize(drawnsCount)) + { + // + AddObjects( + iObjects, + eaDraws // + ); + } + if (HasDirection(marketStructure.trueGapedDir)) + { + Print("true gap detected ..."); + } } // diff --git a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 index e0a04cb7..26f7b328 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.x-poi.drawer.class.mq5 @@ -33,110 +33,740 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer public: // - void DrawMarketStructure( + // + // Get Specified Directional Arrow Anchor ... + ENUM_ARROW_ANCHOR GetArrowAnchor(ENUM_X_DIRECTION forDir) + { + // + ENUM_ARROW_ANCHOR result = ANCHOR_BOTTOM; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? ANCHOR_TOP + : ANCHOR_BOTTOM; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Code ... + int GetArrowCode(ENUM_X_DIRECTION forDir) + { + // + int result = 159; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? 233 + : 234; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Code ... + color GetArrowColor(ENUM_X_DIRECTION forDir) + { + // + color result = clrYellow; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? clrAqua + : clrMagenta; + } + + // + return result; + } + + // + // Get Specified Directional Arrow Price Type ... + ENUM_X_PRICE GetArrowPriceType(ENUM_X_DIRECTION forDir) + { + // + ENUM_X_PRICE result = X_PRICE_CLOSE; + + // + if (HasDirection(forDir)) + { + // + result = + IsSpecifiedBullish(forDir) + ? X_PRICE_LOW + : X_PRICE_HIGH; + } + + // + return result; + } + + /** + * Fill Arrow Based Drawing Specs ... + * + * @param forDir: Specified Direction ... + * @param arrowPriceType: ENUM_X_PRICE, refrence for Arrow Price ... + * @param arrowCode: int, reference for Arrow Code ... + * @param arrowWidth: int, reference for Arrow Width ... + * @param arrowColor: color, reference for Arrow Color ... + * @param arrowAnchor: ENUM_ARROW_ANCHOR, reference for Arrow Anchor ... + */ + void FillArrowSpecs( + ENUM_X_DIRECTION forDir, + ENUM_X_PRICE &arrowPriceType, + int &arrowCode, + int &arrowWidth, + color &arrowColor, + ENUM_ARROW_ANCHOR &arrowAnchor // + ) + { + // + // Prepare ... + arrowCode = 159; + arrowWidth = 3; + arrowColor = CLR_NONE; + arrowAnchor = ANCHOR_BOTTOM; + arrowPriceType = X_PRICE_CLOSE; + + // + if (HasDirection(forDir)) + { + // + arrowCode = GetArrowCode(forDir); + arrowColor = GetArrowColor(forDir); + arrowAnchor = GetArrowAnchor(forDir); + arrowPriceType = GetArrowPriceType(forDir); + } + } + + int DrawMarketStructure( XFIMAMarketStructure &structure, XFIMAMarketStructureDrawerConfig &config, CArrayObj *&objects // ) { + // + int result = 0; + + // + // Normalize ... + if (objects == NULL) + { + objects = new CArrayObj(); + } + // // Prepare ... objects.Clear(); + // + bool has = false; + int arrowCode = -1; + int arrowWidth = 3; + string arrowName = NULL; + color arrowColor = CLR_NONE; + ENUM_X_PRICE arrowPriceType = X_PRICE_CLOSE; + ENUM_ARROW_ANCHOR arrowAnchor = ANCHOR_BOTTOM; + + // + int bullArrowCode = GetArrowCode(X_DIRECTION_BULLISH); + int bearArrowCode = GetArrowCode(X_DIRECTION_BEARISH); + + // + // Validate ... + has = structure.bar.IsValid(); + if (!has) + { + return result; + } + // // Apply Drawing Methods ... // + // OB ... if (config.drawOB) { + // + // Validate ... + has = structure.ob.IsValid(); + if (has) + { + // + XCBoxObject *iObj; + has = DrawBox( + structure.ob, + iObj // + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } } // + // FVG ... if (config.drawFVG) { + // + // Validate ... + has = structure.fvg.IsValid(); + if (has) + { + // + XCBoxObject *iObj; + has = DrawBox( + structure.fvg, + iObj // + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } } // + // Support ... if (config.drawSupports) { + // + // Validate ... + has = structure.support.IsValid(); + if (has) + { + // + XCBoxObject *iObj; + has = DrawBox( + structure.support, + iObj // + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } } // + // Resistance ... if (config.drawResistance) { + // + // Validate ... + has = structure.resistance.IsValid(); + if (has) + { + // + XCBoxObject *iObj; + has = DrawBox( + structure.resistance, + iObj // + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } } // + // Swing Trend ... if (config.drawSwingTrend) { + // + // Validate ... + has = HasDirection(structure.trendDir) && + HasChild(structure.trendSwings); + if (has) + { + // + CChartObjectTrend *iObj; + has = DrawSwingTrend( + structure.trendSwings, + structure.trendDir, + iObj, // + true, // Ray Right ... + false // Ray Left ... + ); + if (has) + { + objects.Add(iObj); + } + + // + ZeroMemory(iObj); + } } // + // Start Pattern ... if (config.drawStarPattern) { + // + // Validate ... + has = HasDirection(structure.starPatternDir); + if (has) + { + // + FillArrowSpecs( + structure.starPatternDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XStar_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Flag Pattern ... if (config.drawFlagPattern) { + // + // Validate ... + has = HasDirection(structure.flagPatternDir) && + structure.flagSwing.IsValid(); + if (has) + { + // + FillArrowSpecs( + structure.flagPatternDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XFlag_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Rising Pattern ... if (config.drawRisingPattern) { + // + // Validate ... + has = HasDirection(structure.risingPatternDir); + if (has) + { + // + FillArrowSpecs( + structure.risingPatternDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XRise_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Piercing Pattern ... if (config.drawPiercingPattern) { + // + // Validate ... + has = HasDirection(structure.piercingPatternDir); + if (has) + { + // + FillArrowSpecs( + structure.piercingPatternDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XPiercing_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Signal Key Bar Pattern ... if (config.drawSignalKeyBarPattern) { + // + // Validate ... + has = HasDirection(structure.signalKeyBarPatternDir); + if (has) + { + // + FillArrowSpecs( + structure.signalKeyBarPatternDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XSignalKey_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Pinned Bar ... if (config.drawPinned) { + // + // Validate ... + has = HasDirection(structure.pinnedDir); + if (has) + { + // + FillArrowSpecs( + structure.pinnedDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XPin_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Momentum Bar ... if (config.drawMomentum) { + // + // Validate ... + has = HasDirection(structure.momentumDir); + if (has) + { + // + FillArrowSpecs( + structure.momentumDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XMomentum_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // Engulfed Bar ... if (config.drawEngulfed) { + // + // Validate ... + has = HasDirection(structure.engulfedDir); + if (has) + { + // + FillArrowSpecs( + structure.engulfedDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XEngulf_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // True Gaped Bar ... if (config.drawTrueGaped) { + // + // Validate ... + has = HasDirection(structure.trueGapedDir); + if (has) + { + // + FillArrowSpecs( + structure.trueGapedDir, + arrowPriceType, + arrowCode, + arrowWidth, + arrowColor, + arrowAnchor // + ); + XCBarArrowObject *iObj; + arrowName = "XTrueGap_" + ToMD5(structure.bar.time); + has = DrawBarArrow( + structure.bar, + iObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + arrowName // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // XFIMA PV Analysis ... if (config.drawFIMAPVPivotsAnalysis) { + // + // Validate ... + has = structure.pvAnalysis.IsValid(); + if (has) + { + // + XCPivotAnalysisObject *iObj; + has = DrawPivotAnalysis( + structure.pvAnalysis, + iObj, + config.drawFIMAPVPivotsAnalysisPivots, + bearArrowCode, + bullArrowCode // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // XFIMA MA Analysis ... if (config.drawFIMAMAPivotsAnalysis) { + // + // Validate ... + has = structure.maAnalysis.IsValid(); + if (has) + { + // + XCPivotAnalysisObject *iObj; + has = DrawPivotAnalysis( + structure.pvAnalysis, + iObj, + config.drawFIMAMAPivotsAnalysisPivots, + bearArrowCode, + bullArrowCode // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // XFIMA Sar Analysis ... if (config.drawFIMASARPivotsAnalysis) { + // + // Validate ... + has = structure.sarAnalysis.IsValid(); + if (has) + { + // + XCPivotAnalysisObject *iObj; + has = DrawPivotAnalysis( + structure.pvAnalysis, + iObj, + config.drawFIMASARPivotsAnalysisPivots, + bearArrowCode, + bullArrowCode // + ); + if (has) + { + objects.Add(iObj); + } + } } // + // XFIMA ZigZag Analysis ... if (config.drawFIMAZigZagPivotsAnalysis) { + // + // Validate ... + has = structure.zigzagAnalysis.IsValid(); + if (has) + { + // + XCPivotAnalysisObject *iObj; + has = DrawPivotAnalysis( + structure.pvAnalysis, + iObj, + config.drawFIMAZigZagPivotsAnalysisPivots, + bearArrowCode, + bullArrowCode // + ); + if (has) + { + objects.Add(iObj); + } + } } // + result = objects.Total(); + + // + return result; } // diff --git a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 index d2f87d11..f86425ad 100644 --- a/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 +++ b/XFIMAEA/Libraries/x-saherelm.xfima.lib.mq5 @@ -264,6 +264,48 @@ struct XFIMAPatternDetectorConfig maxAllowedLoopbackLengthForAnalysis = 1500; } + /** + * Full Detection Model ... + */ + void FullDetect() + { + // + Default(); + + // + // OB / FVG ... + detectOB = true; + detectFVG = true; + + // + // Support and Resistances ... + detectSupports = true; + detectResistance = true; + detectSwingTrend = true; + + // + // Patterns ... + detectStarPattern = true; + detectFlagPattern = true; + detectRisingPattern = true; + detectPiercingPattern = true; + detectSignalKeyBarPattern = true; + + // + // Bars ... + detectPinned = true; + detectMomentum = true; + detectEngulfed = true; + detectTrueGaped = true; + + // + // Analysers ... + analyseFIMAPVPivots = true; + analyseFIMAMAPivots = true; + analyseFIMASARPivots = true; + analyseFIMAZigZagPivots = true; + } + // }; @@ -479,5 +521,38 @@ struct XFIMAMarketStructureDrawerConfig drawFIMAZigZagPivotsAnalysisPivots = false; } + /** + * Configure for Full Drawing ... + */ + void FullDraw() + { + // + Default(); + + // + drawOB = true; + drawFVG = true; + drawPinned = true; + drawMomentum = true; + drawSupports = true; + drawEngulfed = true; + drawTrueGaped = true; + drawResistance = true; + drawSwingTrend = true; + drawStarPattern = true; + drawFlagPattern = true; + drawRisingPattern = true; + drawPiercingPattern = true; + drawSignalKeyBarPattern = true; + drawFIMAPVPivotsAnalysis = true; + drawFIMAMAPivotsAnalysis = true; + drawFIMASARPivotsAnalysis = true; + drawFIMAZigZagPivotsAnalysis = true; + drawFIMAPVPivotsAnalysisPivots = true; + drawFIMAMAPivotsAnalysisPivots = true; + drawFIMASARPivotsAnalysisPivots = true; + drawFIMAZigZagPivotsAnalysisPivots = true; + } + // };