felix Chidubem
felix Chidubem

Reputation: 19

How to get values from 0 to a particular variable in pinescript

am trying to get all numbers from 0 to a variable "history bars + len" in pinesccript, i used the code below but i got an error that it does not returns series int, i need help with rewriting the code

// generate values from 0 to historybars+len
A() =>
    customArray = array.new_int()
    for i = 0 to historyBars +len
        array.push(customArray, i)
    customArray


var ArrayClose = matrix.new<float>(A(),NumCol,historyBars + len)
var ArrayLo = matrix.new<float>(A(),NumCol,historyBars + len)
var ArrayHi = matrix.new<float>(A(),NumCol,historyBars + len) 

Cannot call 'matrix.new' with argument 'columns'='call 'A' (float[])'. An argument of 'float[]' type was used but a 'series int' is expected.

Upvotes: 0

Views: 69

Answers (1)

Starr Lucky
Starr Lucky

Reputation: 1961

https://www.tradingview.com/pine-script-docs/en/v5/language/Matrices.html


if barstate.islastconfirmedhistory
    var ArrayClose = matrix.new<int>()
    ArrayClose.add_col(0, A())
    label.new(bar_index,high, str.tostring(ArrayClose))

Upvotes: 0

Related Questions