Thanks for the suggestion.
I made a few tweaks to the code.
And as to be able to test it correctly, I just use a small part of the code, instead of the whole thing (see below).
My main preoccupation for the moment is that, no matter what I input as “Average[XX](close)”, the rebound only happen on the MA 20 1 minute (where XX = 1200 periods = H1).
I don’t see what’s wrong in the code, really…
// If you wish to change the time unit, don’t forget to adjust the periods of the moving averages (according to the stockmarket’s open hours as well)
// Parameters
myATR = AverageTrueRange[14](close[1]) // Confirmation distance of the pattern from the highest / lowest of the pinbar (on the next candlestick)
distance = 6*PIPSIZE // Limit within which the pinbar must be contained (around each moving average)
ma11 = Average[1200](close) // Moving average 20 (H1) in a 1 minute time unit (for markets open from 9h to 17h30)
// Patterns within MA distance
c01 = High[1] < ma11 + distance AND High[1] > ma11 // High contained above and in the defined limit around the MA
c02 = High[1] > ma11 – distance AND High[1] < ma11 // High contained below and in the defined limit around the MA
c03 = Close[1] < ma11 + distance AND Close[1] > ma11 // Close contained above and in the defined limit around the MA
c04 = Close[1] > ma11 – distance AND Close[1] < ma11 // Close contained below and in the defined limit around the MA
c05 = Low[1] < ma11 + distance AND Low[1] > ma11 // Low contained above and in the defined limit around the MA
c06 = Low[1] > ma11 – distance AND Low[1] < ma11 // Low contained below and in the defined limit around the MA
c07 = High[1] > Open[1] AND High[1] > Close[1] // High > Open & Close
c08 = Low[1] < Open[1] AND Low[1] < Close[1] // Low < Open & Close
// MA – Only 1 MA on 3 kept / Only 1 pattern on 4 kept
IF c06 AND c03 AND c08 THEN
result = 1
ENDIF
// Pinbar + validation + MA
IF result = 2 THEN
IF (high[1] – low[1]) > 2*abs(close[1] – open[1]) THEN
IF (close[1] < open[1]) AND (open[1] – low[1]) < 0.33*(high[1] – low[1]) OR (close[1] – low[1]) < 0.33*(high[1]-low[1]) AND open[0] < (high[1] – myATR) THEN
DRAWARROWDOWN(barindex[1],high[1]+6*TICKSIZE)coloured(255,10,10)
ELSIF (close[1] < open[1]) AND (open[1] – low[1]) < 0.33*(high[1] – low[1]) OR (close[1] – low[1]) < 0.33*(high[1]-low[1]) AND open[0] > (high[1] – myATR) THEN
DRAWARROWDOWN(barindex[1],high[1]+6*TICKSIZE)coloured(255,10,10)
ENDIF
ENDIF
ELSIF result = 1 THEN
IF (high[1] – low[1]) > 2*abs(close[1] – open[1]) THEN
IF (open[1] < close[1]) AND (high[1] – open[1]) < 0.33*(high[1] – low[1]) OR (high[1] – close[1]) < 0.33*(high[1]-low[1]) AND open[0] > (low[1] + myATR) THEN
DRAWARROWUP(barindex[1],low[1]-6*TICKSIZE)coloured(10,255,10)
ELSIF (open[1] < close[1]) AND (high[1] – open[1]) < 0.33*(high[1] – low[1]) OR (high[1] – close[1]) < 0.33*(high[1]-low[1]) AND open[0] > (low[1] + myATR) THEN
DRAWARROWUP(barindex[1],low[1]-6*TICKSIZE)coloured(10,255,10)
ENDIF
ENDIF
ENDIF
RETURN