Does anyone know if there is a code that checks the current or previous candle before allowing a buy short or long?
Might have answered my own question with this:
IF close(1) < open THEN whatever……. (Signals that the current bar is trending upwards and is higher than the previous bar) OR
IF close(1) > open THEN …..(Signals that the previous bar closed higher than the current bar open and thus the current bar is trending downwards).
I think this logic is right…
Yes, you have it stated correctly, the indicator below also confirms other conditions, such as.. the quantity of green/red candles, how many pips their move is, does SuperTrend confirm the trend and what is the height of the bollinger band..
res=0
// Detection of 3 green candles
a1 = open < close and open[1] < close[1] and open[2] < close[2]
a2 = high-low[2]>=5
a3 = SuperTrend[7,10]<(close)
a4 = +3.0*STD[90](close) - -3.0*STD[90](close) >20
// Detection 3 red candles
b1 = open > close and open[1] > close[1] and open[2] > close[2]
b2 = high[2]-low>=5
b3 = SuperTrend[7,10]>(close)
b4 = +3.0*STD[90](close) - -3.0*STD[90](close) >20
if a1 and a2 and a3 and a4 then
res = 1
elsif b1 and b2 and b3 and b4 then
res = -1
endif
return res as "3up3down"