From e384f21c9cc3d86fcf2790ed0c687f120140022f Mon Sep 17 00:00:00 2001 From: Bell Date: Wed, 11 Mar 2026 19:08:21 +0700 Subject: [PATCH] =?UTF-8?q?T=E1=BB=91i=20=C6=B0u=20FVG=20condition,=20l?= =?UTF-8?q?=E1=BB=8Dc=20c=C3=A1c=20fvg=20x=E1=BA=A5u?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Experts/SimpleFVG/Config.mqh | 6 ++++-- Experts/SimpleFVG/FVG.mqh | 29 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Experts/SimpleFVG/Config.mqh b/Experts/SimpleFVG/Config.mqh index 772edaa..3df55fe 100644 --- a/Experts/SimpleFVG/Config.mqh +++ b/Experts/SimpleFVG/Config.mqh @@ -17,8 +17,10 @@ input int InpEMASlowPeriod = 89; input int InpFVGLookbackBars = 100; input int InpFVGMaxAgeBars = 50; input double InpFVGMinBodyPct = 50.0; -input double InpFVGMinSizePoints = 0; -input double InpFVGTouchedPercent = 40.0; +input double InpFVGMinSizePoints = 0; +input double InpFVGTouchedPercent = 40.0; +input double InpFVGMinGapVsImpulsePct = 40.0; +input double InpFVGMaxOuterBarRatio = 2.0; //--- Step 3: Trading --- input bool InpTradeEnabled = true; diff --git a/Experts/SimpleFVG/FVG.mqh b/Experts/SimpleFVG/FVG.mqh index 62d7469..d69623e 100644 --- a/Experts/SimpleFVG/FVG.mqh +++ b/Experts/SimpleFVG/FVG.mqh @@ -164,6 +164,8 @@ void ScanForNewFVGs() double candleA_High = iHigh(symbol, InpTimeframe, shiftA); double candleA_Low = iLow (symbol, InpTimeframe, shiftA); + double candleB_High = iHigh(symbol, InpTimeframe, shiftB); + double candleB_Low = iLow (symbol, InpTimeframe, shiftB); double candleB_Open = iOpen (symbol, InpTimeframe, shiftB); double candleB_Close = iClose(symbol, InpTimeframe, shiftB); @@ -172,14 +174,30 @@ void ScanForNewFVGs() datetime fvgTime = iTime(symbol, InpTimeframe, shiftC); + double rangeA = candleA_High - candleA_Low; + double rangeB = candleB_High - candleB_Low; + double rangeC = candleC_High - candleC_Low; + + if(rangeB <= 0) + continue; + + double maxOuterRatio = InpFVGMaxOuterBarRatio; + if(rangeA > maxOuterRatio * rangeB || rangeC > maxOuterRatio * rangeB) + continue; + + double minGapVsImpulse = InpFVGMinGapVsImpulsePct / 100.0; + //--- Bullish FVG: gap between A.High and C.Low --- if(candleA_High < candleC_Low && candleB_Close > candleB_Open && IsImpulseCandleStrong(symbol, InpTimeframe, shiftB)) { - if(!FVGAlreadyTracked(fvgTime, FVG_BULLISH)) + double gap = candleC_Low - candleA_High; + double gapRatio = gap / rangeB; + + if(gapRatio >= minGapVsImpulse && !FVGAlreadyTracked(fvgTime, FVG_BULLISH)) { - double slRef = iLow(symbol, InpTimeframe, shiftB); // bar2.low + double slRef = candleB_Low; // bar2.low AddFVGZone(FVG_BULLISH, candleC_Low, candleA_High, slRef, fvgTime); } } @@ -189,9 +207,12 @@ void ScanForNewFVGs() && candleB_Close < candleB_Open && IsImpulseCandleStrong(symbol, InpTimeframe, shiftB)) { - if(!FVGAlreadyTracked(fvgTime, FVG_BEARISH)) + double gap = candleA_Low - candleC_High; + double gapRatio = gap / rangeB; + + if(gapRatio >= minGapVsImpulse && !FVGAlreadyTracked(fvgTime, FVG_BEARISH)) { - double slRef = iHigh(symbol, InpTimeframe, shiftB); // bar2.high + double slRef = candleB_High; // bar2.high AddFVGZone(FVG_BEARISH, candleA_Low, candleC_High, slRef, fvgTime); } }