Hi everyone, I'm new to this forum and in searching, I couldn't seem to find the answer to a problem I've been having.
I am trying to write some code so that the price of an /ES, /GC, /CL, etc. futures ATM option appears on my chart.
I'm using the line below, but for some reason, while it works with underlying stocks/ETFs, it doesn't work with futures very well (or in the case of GC and CL, doesn't work at all).
It only sporadically is able to pull the value of the /ES option, otherwise it just returns NaN. Any ideas on how to get this to work better? Thank you!
close(GetATMOption(GetUnderlyingSymbol(), YYYYMMDD, OptionClass.CALL))
I am trying to write some code so that the price of an /ES, /GC, /CL, etc. futures ATM option appears on my chart.
I'm using the line below, but for some reason, while it works with underlying stocks/ETFs, it doesn't work with futures very well (or in the case of GC and CL, doesn't work at all).
It only sporadically is able to pull the value of the /ES option, otherwise it just returns NaN. Any ideas on how to get this to work better? Thank you!

close(GetATMOption(GetUnderlyingSymbol(), YYYYMMDD, OptionClass.CALL))
Last edited by a moderator: