Injecting month variable on tradingview pinescript into security function

Viewed 52

This compiles fine

datecode="0625"
exchange="FTX:BTC"+datecode+"USD"

But if I want to do this it doesn't compile. =month returns 6 so I have to put a zero in front of it. But now datecode needs to be in quotations and I don't know how I go about doing that.

monthA=0
monthB=month
dayx="25"
datecode=monthA+monthB+dayx

exchange="FTX:BTC"+datecode+"USD"
1 Answers

This cannot be done in Pine.
security() requires the symbol parameter to be a fixed string, which doesn't change during script execution.
This is the case in your first example.
Your second example includes month, which will change during script execution, hence the compiler error.

Related