Hi,
I’d like to know how to write a code which allow to check if current candle has a larger body than previous n candles or not. This checking keep repeating when next candle starts.
Thanks
This should do
ONCE n = 20
Body = abs(close - open)
HighestBody = (Body = highest[n](Body))
RETURN HighestBody
That code can also be adapted easily to look for the largest range in n candles.
Numcandles = 20
Rnge = abs(High - Low)
LargestRange = (Rnge = highest[NumCandles](Rnge))
RETURN LargestRange
and also sometimes it is interesting to know when a candle has the smallest body or range in n candles. Quite useful to get out of the market with your profit when the market has gone a bit flat.
NumCandles = 20
Body = abs(close - open)
SmallestBody = (Body = lowest[NumCandles](Body))
Rnge = abs(High - Low)
SmallestRange = (Rnge = lowest[NumCandles](Rnge))