How do i create nest list for my symbols in Pinescript?

53 Views Asked by At

I am trying to create a list selection for symbols. The sets are working, but the exchangeList is not. I want to be able to select the exchange first, and then the sets from that list.

Here is the code that I am using:

exchangeList = input.string("COINBASE", title="Exchange", options=["BINANCE", "COINBASE", "KUCOIN"])
setList = input.string("Set 1", title="Coin Sets", options=["Set 1", "Set 2", "Set 3"])

//Coinbase
string s01 = setList == "Set 1" ? f_ticker('COINBASE:00USD'): setList == "Set 2" ? f_ticker('COINBASE:AMPUSD'): f_ticker('COINBASE:ETHBTC')

//BINANCE
string s01 = setList == "Set 1" ? f_ticker('BINANCE:ETHUSDT'): setList == "Set 2" ? f_ticker('BINANCE:LTCUSDT'): f_ticker('BINANCE:ADAUSDT')

//KUCOIN
string s01 = setList == "Set 1" ? f_ticker('KUCOIN:MATICUSDT'): setList == "Set 2" ? f_ticker('KUCOIN:ETCUSDT'): f_ticker('KUCOIN:SOLUSDT')

I tried the following code and it didn't work:

//KUCOIN
string s01 = exchangeList == "KUCOIN" ? "Coinbase" : setList == "Set 1" ? f_ticker('COINBASE:00USD'): setList == "Set 2" ? f_ticker('COINBASE:AMPUSD'): f_ticker('COINBASE:ETHBTC')

I also tried this:

if exchangeList == "Coinbase"
    string s01 = setList == "Set 1" ? f_ticker('COINBASE:00USD'): setList == "Set 2" ? f_ticker('COINBASE:AMPUSD'): setList == "Set 3" ? f_ticker('COINBASE:AXLUSD'): f_ticker('COINBASE:UNIBTC')

each list starts with string s01 and there are 15 total so I am not sure how to make this happen.

1

There are 1 best solutions below

2
Rakesh Poluri On

This may not be perfect but it is working:

string s = ""

if exchangeList == "BINANCE"
    if setList == "Set 1"
        s := exchangeList + ":" + "ETHUSDT"
    if setList == "Set 2"
        s := exchangeList + ":" + "LTCUSDT"
    if setList == "Set 3"
        s := exchangeList + ":" + "ADAUSDT"

if exchangeList == "COINBASE"
    if setList == "Set 1"
        s := exchangeList + ":" + "00USD"
    if setList == "Set 2"
        s := exchangeList + ":" + "AMPUSD"
    if setList == "Set 3"
        s := exchangeList + ":" + "ETHBTC"

if exchangeList == "KUCOIN"
    if setList == "Set 1"
        s := exchangeList + ":" + "MATICUSDT"
    if setList == "Set 2"
        s := exchangeList + ":" + "ETCUSDT"
    if setList == "Set 3"
        s := exchangeList + ":" + "SOLUSDT"

f_ticker(s)