I am creating a indicator using pine script.Where i want to put conditions based on eache Ticker(Symbol) which exceed in number 500.My script contains more than 500 if statements,as shown in following code.
//@version=4
study("PineTest", "", true)
srcHi = 0.00
srcLo = 0.00
if syminfo.ticker == "AMZN"
srcHi:=2000.00
srcLo:=1670.00
if syminfo.ticker == "SPY"
srcHi:=300.00
srcLo:=210.00
if syminfo.ticker == "AAPL"
srcHi:=300.00
srcLo:=170.00
if syminfo.ticker == "MSFT"
srcHi:=210.00
srcLo:=50.00 `
diff = srcHi - srcLo
p1=plot(diff, title = "diff", color = #000000, transp= 0, offset=0,
trackprice = true, linewidth = 2)
I just added 4 if statements in above code.If i try to add more than 500 if statements likewise i will get an above error:script has too many local scopes.How can i solve this Error without minimizing number of if conditions? If function needs to be used for this purpose then please tell me how to do that with this code?