LéoParticipant
Average
Hi All,
I am trying to write a very simple screener that will show the break of eMM7 for Close[1]
To avoid too many results I would like to make sure that the 5 previous closes were below th eMM7 also.
Cf below.
It does not work at all so I assume my entries are not correct.
Can anyone help ?
Thanks.
C1= Close[1] > exponentialaverage[7](close[1]) and close[2]<exponentialaverage[7](close[2])and close[3]<exponentialaverage[7](close[3])and close[4]<exponentialaverage[7](close[4])and close[5]<exponentialaverage[7](close[5])and close[6]<exponentialaverage[7](close[6])
C2= Close[1] < exponentialaverage[7](close[1]) and close[2]>exponentialaverage[7](close[2])and close[3]>exponentialaverage[7](close[3])and close[4]>exponentialaverage[7](close[4])and close[5]>exponentialaverage[7](close[5])and close[6]>exponentialaverage[7](close[6])
SCREENER[C1 or C2]
The below screener code should work as expected. On the current candle, the price is breaking the exponential average 7 periods while the 5 previous candlesticks Close were above or below the average.
ema7 = exponentialaverage[7](close)
signal = 0
if close crosses over ema7 and summation[5](close<ema7)[1]=5 then
signal = 1
elsif close crosses under ema7 and summation[5](close>ema7)[1]=5 then
signal = -1
endif
screener[signal<>0](signal as "direction")
Bullish signal is labelled “1” and bearish is “-1” in the sorting criteria column.
LéoParticipant
Average
Thank you Nicolas,
It can also be interesting for users of PRTBands
PRTBands = prtbandsshortterm
signal = 0
if close crosses over PRTBands and summation[5](close<PRTBands)[1]=5 then
signal = 1
elsif close crosses under PRTBands and summation[5](close>PRTBands)[1]=5 then
signal = -1
endif
screener[signal<>0](signal as "direction")