To all you TOS Scripters out there, I need help :-) Below is my script that sort of works – but have a few...
To all you TOS Scripters out there, I need help :-)
Below is my script that sort of works – but have a few questions.
Goal is to make it easier to find options when I am going through the tickers and looking at the charts for I/A/OTM options and calculate a return on Option for a covered call / diagonal
1: How can I get the next monthly option expiration automatically with out hard coding the date.
2: How do I get the strike price of the option for all 3 scenarios below, as I would like to work out time value of each option.
3: Can I get my margin% automatically?
4: Performance seems to be super slow in getting the options back?
5: How can one do string operations on the result from GetATMOption as it returns a double but the value for example is .YELP171215C45
Thanks
Karl
input expirationDate = 20171216;
input marginPercentage=50;
input rooTarget=4.5;
def StockPriceClose = close(GetSymbol())*(marginPercentage/100);
def ITMOptionClose = close(GetNextITMOption(GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL)));
def rooITM = Round((ITMOptionClose / StockPriceClose) * 100, 1);
AddLabel(IsOptionable(), " MARGIN=" +marginPercentage+ "% EXP Date = " + expirationDate + " ITM=" + GetNextITMOption(GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL)) + " ,c=" + ITMOptionClose + " ROO=" + rooITM + "%", color = Color.LIGHT_ORANGE);
def ATMOptionClose = close(GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL));
def rooATM = Round((ATMOptionClose / StockPriceClose) * 100, 1);
AddLabel(IsOptionable(), "ATM=" + GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL) + ", c=" + ATMOptionClose + " ROO=" + rooATM + "%", if rooATM >= rooTarget then Color.GREEN else Color.RED);
def OTMOptionClose = close(GetNextOTMOption(GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL)));
def rooOTM = Round((OTMOptionClose / StockPriceClose) * 100, 1);
AddLabel(IsOptionable(), " OTM=" + GetNextOTMOption(GetATMOption(GetSymbol(), expirationDate, OptionClass.CALL)) + " ,c=" + OTMOptionClose + " ROO=" + rooOTM + "%", color = Color.LIGHT_ORANGE);
#TechnicalAnalysis
Comments
Start the Conversation
Thanks Tim
Very interesting and inspiring topic Karl!
I've been thinking of Theta Research journal automation or semi-automation. For example, I would want to write a script which will derive …more
Fernando Rodriguez no problem, sure I will share it :)
This is my latest script I have been playing with TOS is a little limiting and un-reliable. The script does not always work. Please not this is is still test - so contains a tone of comments / irrelevant stuff. …more
I'm thinking maybe to add a custom column to Option Chain would be easier than a box to a chart...
Unfortunately, I haven't fooled around with custom code in far too long and I don't totally understand your end goal so it makes it hard to decipher your current code. I've never experimented with the Option Related section of the code either so …more