Get ATM straddle and OTM strangle price in ThinkorSwim?

T

thinky

Member
How do you get the ATM straddle price, first OTM strangle price, and second OTM strangle price? Some underlyings are $1 wide, while others $2.5 or $0.5.

Example ($1 wide):
ABC trades at 100
ATM Straddle is 100
OTM Strangle is 99/101
OTM Strangle is 98/102
 
Last edited:
RobertPayne

RobertPayne

Member
input TargetRatio = 1.015;
input barexit = 2;
def LongTarget = LongEnt * TargetRatio;
def LongExt= LongTarget or LongEnt from barexit bars ago;
AddOrder(OrderType.SELL_TO_CLOSE, LongExt, close, TradeSize);

In the statement highlighted above, you are trying to set LongTarget as the order entry price * the TargetRatio. However, the variable LongEnt is NOT the order entry price. Recall that you defined that variable as your entry conditions. So, it is a boolean condition. That means it will have a value of either true or false which is interpreted by the computer as either a 1 or a 0.

So, def LongTarget = LongEnt * TargetRatio; will either be 1 * 1.015 or 0 * 1.015. Neither of which is what you intended.

Take a look at this reference regarding the EntryPrice() function.

I believe what you want is something along the lines of this:

Ruby:
input TargetRatio = 1.015;
input barexit = 2;
def LongTarget = EntryPrice() * TargetRatio;
def LongExt= (close >= LongTarget) or (LongEnt from barexit bars ago);
AddOrder(OrderType.SELL_TO_CLOSE, LongExt, close, TradeSize);
 
RobertPayne

RobertPayne

Member
@RobertPayne How do you get the ATM straddle price, first OTM strangle price, and second OTM strangle price? Some underlyings are $1 wide, while others $2.5 or $0.5.

Example ($1 wide):
ABC trades at 100
ATM Straddle is 100
OTM Strangle is 99/101
OTM Strangle is 98/102

Whew....this is, certainly, not pretty; but, here is the best I could come up with.



Ruby:
input expirationDate = 20191019;

AddLabel(IsOptionable(), "ATM Call: " + GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL), Color.UPTICK);
AddLabel(IsOptionable(), "1st OTM Call: " + GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)), Color.GREEN);
AddLabel(IsOptionable(), "2nd OTM Call: " + GetNextOTMOption(GetNextOTMOption(GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL))), Color.LIGHT_GREEN);

Take a look at the option related functions then do something similar on the PUT side.
 
T

thinky

Member
@RobertPayne Thanks. It seems TS doesn't provide the means to get price from codes.
 
RobertPayne

RobertPayne

Member
@RobertPayne Thanks. It seems TS doesn't provide the means to get price from codes.

Sure it does. Just make certain that you use the EntryPrice() function after the buy order code.

For example, let's say we want to initiate a BUY order when the MA5 crosses above the MA13. Then, we want to SELL when the closing price is at least $2.00 higher than the purchase price. That can be accomplished with the following code.

Ruby:
def MA5 = Average(close, 5);
def MA13 = Average(close, 13);
def buyCondition = MA5 crosses above MA13;
AddOrder(OrderType.BUY_TO_OPEN, buyCondition, open[-1], 100, Color.UPTICK, Color.UPTICK, "BTO");
def sellCondition = close >= EntryPrice() + 2;
AddOrder(OrderType.SELL_TO_CLOSE, sellCondition, open[-1], 100, Color.DOWNTICK, Color.DOWNTICK, "STC");

 
T

thinky

Member
@RobertPayne You get OPRA codes for options with the function:

GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)

How do you get price using that function? The code you posted last doesn't seem to use it.

If this is at all possible in ThinkScript, I need to get the prices of individual options (legs), then come up with prices for the ATM Straddle and OTM Strangles, then add those numbers. But the problem is getting the option prices in the first place.

OptionPrice() function is the only function related to pricing and doesn't seem to use OPRA codes (doesn't use the other function above).

One issue with that function is that it asks for interest rate and yield.

Sure it does. Just make certain that you use the EntryPrice() function after the buy order code.

For example, let's say we want to initiate a BUY order when the MA5 crosses above the MA13. Then, we want to SELL when the closing price is at least $2.00 higher than the purchase price. That can be accomplished with the following code.

Ruby:
def MA5 = Average(close, 5);
def MA13 = Average(close, 13);
def buyCondition = MA5 crosses above MA13;
AddOrder(OrderType.BUY_TO_OPEN, buyCondition, open[-1], 100, Color.UPTICK, Color.UPTICK, "BTO");
def sellCondition = close >= EntryPrice() + 2;
AddOrder(OrderType.SELL_TO_CLOSE, sellCondition, open[-1], 100, Color.DOWNTICK, Color.DOWNTICK, "STC");
 
Last edited:
RobertPayne

RobertPayne

Member
GetATMOption(GetUnderlyingSymbol(), expirationDate, OptionClass.CALL)

How do you get price using that function? The code you posted last doesn't seem to use it.

I misunderstood your original request. I thought you were just looking for the symbols, which is the difficult part.

Alright, now that you do have the symbols, it's a simple matter to use that information to get the price.

Let me ask you, how would you show the ask price for AAPL while viewing a GOOGL chart?

The answer is found here: Thinkscript fundamentals functions.

By applying what you already know about obtaining the option's symbol and what you learned from the above link, you can achieve this:

 
Last edited:
T

thinky

Member
@RobertPayne Got it working, thanks.

EDIT: The option function (returns a code) can be used with a fundamental function (returns price) to get the option price:

close(symbol = GetATMOption(GetUnderlyingSymbol(), Date, OptionClass.CALL))
 
Last edited:
RobertPayne

RobertPayne

Member
@RobertPayne Got it working, thanks.

EDIT: The option function (returns a code) can be used with a fundamental function (returns price) to get the option price:

close(symbol = GetATMOption(GetUnderlyingSymbol(), Date, OptionClass.CALL))

To add to what thinky posted, if you want the bid / ask price of an option, use the following

Ruby:
def expDate = 20191019; #options expiration date
def bidPrice = close(symbol = GetATMOption(GetUnderlyingSymbol(), expDate, OptionClass.CALL), priceType = PriceType.BID);
def askPrice = close(symbol = GetATMOption(GetUnderlyingSymbol(), expDate, OptionClass.CALL), priceType = PriceType.ASK);
 
S

samks_30

New member
2019 Donor
Hello @RobertPayne

When i try to plot ATM option close price on the chart as a line instead of a label, the line blinks between price and N/A (or 0), and totally repaints the ATM close price when underlying price changes. Is it possible to have the indicator plot line stay without disappearing whenever the underlying price fluctuates?

For example, at market open let's say 250 is the ATM option strike and after few mins 255 is the ATM option strike. Can we draw the indicator by dynamically taking in the ATM option price and continue draw the line as price changes without having the issue of repainting the entire plot?

Thanks!
 
B

Breckfast

New member
I have a chart layover in the top left corner that says "DayRange x.xx vs ATR: x.xx" many of you may be familiar with this modification. I'm looking for a similar layover that takes into account the stock price, ATR, and the price of the shortest expiration ATM put and call options. The input could be bid, ask, last. The idea is that I'm looking for a quick way to quantify what a "cheap" or "expensive" option would be while looking at the chart. I hope I'm I being clear? Does this exist? Would anyone be willing to create it? Thank you for considering my idea, I hope to hear from some of you soon
 
Shooters_Gotta_Shoot

Shooters_Gotta_Shoot

Member
Hey everyone, I have been having a hard time trying to figure out how to code a label for my chart that grabs the current "at the money option" for SPY. I have been day trading / scalping SPY Options and it would be very helpful to not have to leave my 'Charts and Active Trader' Tab to go a look the Option Chain in the 'Trade'Tab. If it would be be possible to look at the option chain while still on the charts tab and I just don't know how...that would be an even better solution, but second best would to just have an automatic label updating me which option in currently at the money so I'm not jumping around different tabs all the time.

This is the TOS Help Center for the script...I just haven't been able to figure it out. --> https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Option-Related/GetATMOption

Any help would be greatly appreciated! Thanks everyone!
 
rad14733

rad14733

Well-known member
VIP
@Shooters_Gotta_Shoot It appears that the option functions aren't working for some reason... I can't get any code using them to work, not even the examples in the Learning Center... Odd... I thought I had them working a couple months ago but none seem to work for me today...
 
Shooters_Gotta_Shoot

Shooters_Gotta_Shoot

Member
@rad14733 I've been having the same issues...is it because the market is currently closed? I tried them with OnDemand and nothing appears either. Seems odd. I guess the other solution is to have the option chain as a completely separate window / these renko charts need to make me enough money to buy another monitor soon!
 
Shooters_Gotta_Shoot

Shooters_Gotta_Shoot

Member
@RobertPayne just wanted to let you know that these aren't working for some reason. I tried them over the weekend and nothing appeared, so I wanted to wait till the market was active today and still no response from the program. The labels appear but the actual options don't appear.
 
rad14733

rad14733

Well-known member
VIP
@RobertPayne just wanted to let you know that these aren't working for some reason. I tried them over the weekend and nothing appeared, so I wanted to wait till the market was active today and still no response from the program. The labels appear but the actual options don't appear.
Option functions are broken in TOS... :mad:
 
Thread starter Similar threads Forum Replies Date
R Plotting ATM call price Questions 0
P Option Straddle based on Moving Average Questions 18
D Alert for Probability OTM changes? Questions 1

Similar threads

Top