i am using an indicator which draws a trendline between two pivot low points, named L1CurrentPivotLowIndex and L1lastPivotLowIndex for the bar indices.
now i am trying to do the following:
for every candle between the to index points i want to:
- store the value of the trendline into an array (works)
- store the high of every candle into an array (gives me wrong values)
- calculate the difference between the trendline and the high and store it into an array (would work if the highs were correct)
Here is a screenshot of the label which prints all values to see if they are correct
the code is the following:
Distance_Array_Size = 15
var L1L_Distance_Array = array.new_float(Distance_Array_Size, na)
var L1L_Line_Array = array.new_float(Distance_Array_Size, na)
var L1L_High_Array = array.new_float(Distance_Array_Size, na)
for i = L1lastPivotLowIndex to L1CurrentPivotLowIndex
L1L_Line = line.get_price(L1_lowLine, i)
array.push(L1L_Line_Array, L1L_Line)
array.shift(L1L_Line_Array)
L1L_High = high, i
array.push(L1L_High_Array, L1L_High)
array.shift(L1L_High_Array)
L1L_Distance = L1L_High - L1L_Line
array.push(L1L_Distance_Array, L1L_Distance)
array.shift(L1L_Distance_Array)
L1L_Label = Use_L1? label.new(L1CurrentPivotLowIndex, L1CurrentPivotLow, "Line: " + str.tostring(L1L_Line_Array, "0.00") + "\nHigh: "+ str.tostring(L1L_High_Array, "0.00")+ "\nDistance: "+ str.tostring(L1L_Distance_Array, "0.00"), style=label.style_label_up):na
label.delete(L1L_Label[1])
can anybody help me solve the two following problems:
- i currently use a fixed Array Size for testing purposes (my example has 12 bars). How can i switch the array size accordingly, so it is dynamic depending on the number of bars between the two pivot points.
i already tried "Distance_Array_Size = L1CurrentPivotLowIndex - L1lastPivotLowIndex", but then the label stays empty.
- how can i get the correct high values for each candle?