The TOS Learning Center example of the GetATMOption function works great for monthly expirations, but I can't seem to get it to work for SPX weekly expirations. I've already tried replacing the "GetUnderlyingSymbol" with "SPXW", which is the symbol used when charting its option prices, but I still can't get it to work. Does anybody have any ideas? I eventually want to use this information to price the straddle, which will then be used to estimate the Expected Move on an intraday basis.
input expirationDate = 20211210; AddLabel(IsOptionable(), "ATM Call option is " + GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL));