Wen trend retraces between 20 and 40 sma,and a new candle breaks previous candle close,

wen trend retraces between 20 and 40 sma, and a new candle breaks previous candle close(( which lies between 20 and 40 sma).

i know code to write for 20 crosses 40,

but how to trace a candle between 20 and 40,and it breaks previous candle,any similar ideas to achieve this?

hElLO tRaDeR,

TRADESCRIPT:

SMA(CLOSE,20) > SMA(CLOSE,40) AND 
CLOSE > REF(CLOSE,1) AND 
CLOSE < SMA(CLOSE,20) AND 
CLOSE > SMA(CLOSE,40) 

First line of the code has been used to identify an uptrend ,  you can remove this if not required.

Try it and let me know, how it works out for you.

thank you,i will check with this