Need code snippet for the condition

Do share a code snippet to define range of a candle. I want to define if range of the current bar is greater than the range of defined number of previous bars. Range means high to low of a candle.

Try using

High_Range = (H - L) > Ref(HHV((H-L),10),-1);

Low_Range = (H-L) < Ref(LLV((H-L),10), -1);

High_Range = ExRem(High_Range,Low_Range);

if(SelectedValue(High_Range) == 1 AND SelectedValue(C > O)) Say("Positive High Range bar for last 10 candles");

if(SelectedValue(High_Range) == 1 AND SelectedValue(C < O)) Say("Negative High Range bar for last 10 candles");

Regards

Vivith

www.neotradeanalytics.com

(authorized real time data vendor supporting feeds to Amibroker/Metastock and Ninjatrader)

1 Like

please note, i have used period of last 10bars. You can set your own period and use in the code.
Regards
Vivith
www.neotradeanalytics.com

Thanks , this helped. On another note, ive put buy and sell conditions. Now instead of plotting buy sell arrows with the code that i already have, what if i want to plot dots in the middle of the body of candlestick.