1

I try to make a simple indicator for each timframe and I did it only that in inputs something like this and I must reduce them with conditional if

I want the show last as the offset to change at different times 4h 2h 1h 30m 15m but the code is long because I have several this is a simple code it works normally if the conditional if but when I put the if so that the condition changes value no change


a = 0
b = 0
if  timeframe.period =="240"
    a:= 30
    b:= 30
//
if timeframe.period =="120"
    a:= 60
    b:= 60

bgcolor( showSemanal2 and isTue2()  ? semanalcolor : na, title="inicio semanal color", show_last = b, offset = a)   

bgcolor( showSemanal2 and isTue2()  ? semanalcolor : na, title="inicio semanal color" , show_last = b ) 

bgcolor( showSemanal and isTue2() ? semanalcolor : na)```



I expected it to change in each timeframe but it didn't work out I hope you can help me

1 Answers1

1

show_last only takes input integer, which means a constant. Here is a possible work around.

var show30 = timeframe.period=="240"
var show60 = timefram.period=="120"


bgcolor( showSemanal2 and isTue2() and show30  ? semanalcolor : na, title="inicio semanal color", show_last = 30, offset = 30)   
bgcolor( showSemanal2 and isTue2() and show30 ? semanalcolor : na, title="inicio semanal color" , show_last = 30) 

bgcolor( showSemanal2 and isTue2() and show60  ? semanalcolor : na, title="inicio semanal color", show_last = 60, offset = 60)   
bgcolor( showSemanal2 and isTue2() and show60 ? semanalcolor : na, title="inicio semanal color" , show_last = 60 ) ```
John Baron
  • 291
  • 2
  • 8