I am trying to calculate AssetValue for the currently selected chart’s symbol, and I’m stuck on looping through the tickers and asset values. Any suggestions on how to loop through them?
This is my code:
// Assets for tickers
ticker1 = input.symbol("KUCOIN:BTCUSDT", title="1", inline = "1", group = "Tickers / Assets")
ticker2 = input.symbol("BINANCE:ETHUSDT", title="2", inline = "2", group = "Tickers / Assets")
// (other 7 tickers)
asset1 = input.float(10, title = "", inline = "1", group = "Tickers / Assets")
asset2 = input.float(10, title = "", inline = "2", group = "Tickers / Assets")
// (other 7 asset values)
AssetTableOn = input(true,"Show Asset Table")
ticker = syminfo.ticker
prefix = syminfo.prefix
fullticker = prefix + ":" + ticker
// Loop through all tickers and corresponding assets
for i = 1 to 9
currentTicker = ticker(i)
currentAsset = asset(1)
if (fullticker == currentTicker)
Assets = currentAsset
AssetValue = currentAsset * close
break
AssetStr = str.tostring(Assets, '#,###.##')
AssetValueStr = str.tostring(AssetValue, '#,###.##')
if (AssetTableOn == true)
// create table
New contributor
jnestor3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.