Code:
def atmCallOption = GetATMOption(GetUnderlyingSymbol(), GetNextExpirationOption(), OptionClass.CALL);
def atmPUTOption = GetATMOption(GetUnderlyingSymbol(), GetNextExpirationOption(), OptionClass.PUT);
plot callDelta = Delta(atmCallOption);
plot putDelta = Delta(atmPUTOption);
i wanna display the delta of call and put options for nearest experation of the underlaying symbol thats open in the chart
there are several issues with your formulas,
def atmCallOption = GetATMOption( GetUnderlyingSymbol(), GetNextExpirationOption(), OptionClass.CALL );
you are using GetATMOption() wrong.
GetATMOption() creates an option symbol, a text value.
def is used for assigning numbers.
you have a wrong parameter for GetATMOption( ), the 2nd one. it should be a date.
GetNextExpirationOption() , is an option symbol.
if a saturday date is used as the 2nd parameter, and the GetATMOption( ) is put inside of a close( ), then it will read a price value.
Code:
# needs to be a sat date
input date1 = 20230318;
def atmCallOption = close( GetATMOption(GetUnderlyingSymbol(), date1, OptionClass.CALL ));
addlabel(1, ("atm " + (GetATMOption( GetUnderlyingSymbol(), date1, OptionClass.CALL )) + " " + atmCallOption) , color.yellow);
-------------------
if an option symbol is in a watchlist, and picked, this will show a delta number
Code:
def delta3 = delta( close(getUnderlyingSymbol()) , imp_volatility(getUnderlyingSymbol()) );
addlabel(1, "delta3 " + delta3, color.cyan);
----------------------------
GetATMOption
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related/GetATMOption
GetNextExpirationOption
Returns the code of the option of the specified series, which has the strike price closest to the current market price.
You can specify the series by defining,
. underlying symbol, expiration date, and option type (Put or Call).
returns the code of the option with the same strike price as the input one, but belonging to the next series.
https://tlc.thinkorswim.com/center/...ctions/Option-Related/GetNextExpirationOption
GetUnderlyingSymbol
https://tlc.thinkorswim.com/center/.../Functions/Option-Related/GetUnderlyingSymbol
Delta
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related/Delta