I have a pinescript indicator and I want to plot lines when that indicators conditions are satisfied in last 14 candles and there is specific tsi and stochastic rsi conditions being met.
Indicators conditions
if buy_goodf or buy_greatf or buy_incrediblef
line.new(bar_index[0], low-lineheightbottom*LineLength, bar_index[0], high+lineheighttop*LineLength, color=color.new(color.lime, 50), width=linewidth)
if sell_goodf or sell_greatf or sell_incrediblef
line.new(bar_index[0], low-lineheightbottom*LineLength, bar_index[0], high+lineheighttop*LineLength, color=color.new(color.red, 50), width=linewidth)
So this part works well, I tested that lines are showing correctly.
But now I want to plot a blue line at every candle where:-
In the last 14 candles there has been a buy line ( that is
buy_goodf or buy_greatf or buy_incrediblefhas satisfied.There is tsi and stochrsi are a certain way.
The only problem I am having is with the first point - how to check for every candle if in its last 13 candles there have a buy condition or not.
I tried coding it using a for loop like this, but this does not give me signals.
for i = 0 to 13
if (buy_goodf or buy_greatf or buy_incrediblef) and tsi_value>tsi_ema and tsi_value[1]<tsi_ema[1] and k[1]<d[1] and k>d
line.new(bar_index[0], low-lineheightbottom*LineLength, bar_index[0], high+lineheighttop*LineLength, color=color.new(color.blue, 50), width=linewidth)
Is this the correct way of doing it?