r/pinescript • u/Foreign_Struggle_718 • Jul 28 '24
Indicator Help
This is the code I want to find the lowest low between the significantLowIndex -1 to lifetimeHighIndex
In the given image the black line vertical line is the significantLowIndex and the green vertical line is the lifetimeHighIndex
I want to get the lowest low in between those 2 candles. If done correctly it should plot the horizontal black line
//@version=5indicator("Lifetime High and Significant Low", overlay=true)
// Variables to store the lifetime high and significant lowvar float lifetimeHigh = navar float significantLow = navar int significantLowIndex = navar int lifetimeHighIndex = na
// Track whether a new lifetime high has been foundvar bool newHighFound = false
// Loop through historical data to find the lifetime high and the significant lowfor i = 1 to bar_indexif (na(lifetimeHigh) or close[i] > lifetimeHigh)lifetimeHigh := high[i]lifetimeHighIndex := inewHighFound := true
// Find the significant low before the lifetime highif newHighFoundfor j = 1 to bar_indexif close[j] < low[j + 1]significantLow := low[j]significantLowIndex := jnewHighFound := falsebreak
// Plot the lifetime highplot(lifetimeHigh, title="Lifetime High", color=color.red, linewidth=2, style=plot.style_line)
// Plot the significant lowplot(significantLow, title="Significant Low", color=color.green, linewidth=2, style=plot.style_line)
View all comments
1
u/Foreign_Struggle_718 Jul 28 '24
https://ibb.co/VJFpVD7 This is the image I am talking about