Greetings,
On the AccumDistBuyPr indicator, I'm trying to generate two auto trendlines with extensions from the last two highs if the current bar close is lower and from the last two lows if the current bar close is higher. Unfortunately, I couldn't figure out how to fetch the previous high/low to connect and create the trendline. Attached is the example screenshot and thinkscipt code. I have color-coded AccumDistBuyPr to show if the current bar is lower/higher than the previous bar. I've been drawing the trendlines manually and it's tiresome. . Any help is much appreciated. Great day to all.
On the AccumDistBuyPr indicator, I'm trying to generate two auto trendlines with extensions from the last two highs if the current bar close is lower and from the last two lows if the current bar close is higher. Unfortunately, I couldn't figure out how to fetch the previous high/low to connect and create the trendline. Attached is the example screenshot and thinkscipt code. I have color-coded AccumDistBuyPr to show if the current bar is lower/higher than the previous bar. I've been drawing the trendlines manually and it's tiresome. . Any help is much appreciated. Great day to all.
Code:
#added ColorCode - ShancR
declare lower;
def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;
plot AccDist = TotalSum(data);
AccDist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
AccDist.DefineColor("Up", GetColor(1));
AccDist.DefineColor("Down", GetColor(0));
AccDist.AssignValueColor(if AccDist > AccDist[1] then AccDist.color("Up") else AccDist.color("Down"));