I am trying to use this code but it only seems to register the factals in the CP periods. e.g If a buy signal is formed, it seems to only look at the high factals within the 20(cp) periods. If there is no high factal within that period it dosent look at the last ‘high’ factal.
I hope I am making sense.
cp = 20
if high[cp] >= highest[2*cp+1](close) then
LH = 1
else
LH = 0
endif
if low[cp] <= lowest[2*cp+1](close) then
LL = -1
else
LL = 0
endif
if LH = 1 then
TOPy = high[cp]
TOPx = barindex[cp]
endif
if LL = -1 then
BOTy = low[cp]
BOTx = barindex[cp]
endif
timeframe (default)
//////////////////////
C1 = (close CROSSES OVER TOPy)
D1 = (close CROSSES UNDER BOTy)
How do I make it so that close crosses over the last TOPy not just the last TOPy within the 20 periods?
I attached a screenshot for better understanding
My sincere apologises. I had just realised the chart is in heikin ashi! Otherwise it seems to be working as intended.