R.Bar
R.Bar

Reputation: 362

Pinescript if else according to the current timeframe

I'm trying to set different values according to a different timeframes

if (period == "60") // also (period == 60) and (period == '60') failed
    len1 = 48
    len2 = 96
    len3 = 480
    len4 = 800

this is what I tried so far but this is not working, I have no clue how to debug pinescript and figure out what's the problem, thanks

Upvotes: 0

Views: 949

Answers (1)

Michel_T.
Michel_T.

Reputation: 2821

to assign a value to already declared variable you need to use := operator rather than :

//@version=3
study("My Script")
len1 = 0
if (period == "60")
    len1 := 48

plot(len1)

Upvotes: 1

Related Questions