pine script - Pinescript - problems with arrays - Stack Overflow

i am using an indicator which draws a trendline between two pivot low points, named L1CurrentPivotLowIn

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:

  1. 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.

  1. how can i get the correct high values for each candle?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744281320a4566584.html

相关推荐

  • pine script - Pinescript - problems with arrays - Stack Overflow

    i am using an indicator which draws a trendline between two pivot low points, named L1CurrentPivotLowIn

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信