3

i am trying to implement different behaviors of the script depending on the current symbol that is opened, how do i check the name of the symbol?

for example (pseudocode):

if the symbol is CADJPY - do this

else if the symbol is NAS100USD - do this

1 Answers1

4

You can use syminfo.ticker to get the symbol name without exchange prefix e.g. MSFT, or syminfo.tickerid to get the symbol name with exchange prefix e.g. NASDAQ:MSFT.

vitruvius
  • 15,740
  • 3
  • 16
  • 26
  • does both methods return a string? so using the syminfo.ticker would be this way (example): symbol = syminfo.ticker if symbol == "EURUSD" //do this else if symbol == "NAS100USD" // do this –  Jun 05 '22 at 14:13
  • 1
    Both return `simple string`. – vitruvius Jun 05 '22 at 16:45