Hi folks, new to thinkscript. I am trying to plot price levels using daily high/low values. Basically if the day close is +/- 2% from the prior day high or low, then plot a price line at prior day close.
The code is a rather simpler implementation. I am looking at last day close and comparing the change with the current day close.
How do I plot the multiple price levels -- extending to the right.
I suspect I have to use "fold" somehow ?
The code is a rather simpler implementation. I am looking at last day close and comparing the change with the current day close.
How do I plot the multiple price levels -- extending to the right.
I suspect I have to use "fold" somehow ?
Code:
def price = close(period="DAY");
def change = (absValue(price [1] -price)/price [1]) * 100 ;
def level = if change>= 2 then price else Double.nan; # 2% change
plot p01 = (if !isNan(level) then level else double.nan);