Options: Buying and Selling At-The-Money Option In Strategy?

Solution
Thanks Halcy. I found a workaround that works good enough for what I'm trying to do.
- I went to Trade -> All Products (it could probably also be done under the Analyze tab).
- On the Trade grid, I turned on 2 columns and as many rows as possible. Then shrunk all the bottom grids and expanded the top 2 as tall as they could go.
- On the right grid, I have the stock with the strategy I want to look at.
- Then on the left grid, I can enter in whichever option I want to look at. The option chain doesn't have any past expiration dates, but you can still pull up past expirations as long as you enter the long form option string name in the ticker box. I have a separate strategy on the option chart where I can just tell it what date and...
You cannot code options into strategy, however you can use a workaround (very tedious to code), as any entry and exit will be based on some price action. You can certainly identify ATM option price at those price points and display using label or chart bubble, good luck! (y)
 
Wondering if it's possible to program the strategy feature to buy an ATM option to and backtest its performance rather than just simply 1 share of stock. I'm aware that something similar can be done under the thinkback feature, but I don't believe you can program strategies in the thinkback feature.

Edit: When I say strategy, I mean the strategy feature inside the studies tab where you backtest things. Not just a general strategy.

a strategy will run on a chart symbol. so if an option symbol is entered into the symbol field, then a strategy will run on it.
i added a cisco option symbol to my watchlist and selected it.
.CSCO220121C60
i added the strategy below to the chart and it signaled buys and sells.


if you want to enter a stock symbol, and have a strategy run on an option of the stock, maybe it would work? i haven't tried this.
you would have to
. replace open[-1]
. with open( option symbol )[-1]



Ruby:
#  test_option_strategy_0

#https://usethinkscript.com/threads/zigzag-high-low-with-supply-demand-zones-for-thinkorswim.172/#post-7048
# robert

# define swing high and low points
input length = 10;
def bn = BarNumber();
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);
def offset = Min(length - 1, lastBar - bn);

def swingLo = low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);
def swinghi = high > highest(high[1], length - 1) and high == GetValue(highest( high, length), -offset);

input verify_signals = no;
addverticalline(verify_signals  and swinglo, "low", color.red);
addverticalline(verify_signals  and swinghi, "hi", color.green);

def buy = swinglo;
def sell = swinghi;

input order_size = 1;

addOrder(OrderType.BUY_TO_OPEN, buy, open[-1], order_size, color.green, color.green, "buy");

addOrder(OrderType.SELL_TO_CLOSE, sell, open[-1], order_size, color.red, color.red, "sell");

# AddOrder ( int type, IDataHolder condition, IDataHolder price, IDataHolder tradeSize, CustomColor tickColor, CustomColor arrowColor, String name);   
#
#


if you want to test the profitability of a strategy on an option, maybe your strategy could be changed into a study, and add a profit/loss study added to the end of it.
this assumes your code has the ATM symbol.

here is a profit/loss study i made.
https://usethinkscript.com/threads/label-with-information-related-to-strategy.7902/#post-75825
the code would be copied to the end of your study.
then the following formulas would be changed to = your buy and sell signals.
close would have to be changed to = the option close, close( option symbol )

def long_open = 0;
def short_open = 0;
def long_close = short_open;
def short_close = long_open;



maybe this study can be altered to generate the desired option data
https://usethinkscript.com/threads/capture-option-chain-data-via-thinkscript.3871/#post-42708
# Weekly Options Implied Volatility Plotted intraday
# Mobius
# Chat Room Request
# 02.27.2016

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder
 
Last edited by a moderator:
Thanks Halcy. I found a workaround that works good enough for what I'm trying to do.
- I went to Trade -> All Products (it could probably also be done under the Analyze tab).
- On the Trade grid, I turned on 2 columns and as many rows as possible. Then shrunk all the bottom grids and expanded the top 2 as tall as they could go.
- On the right grid, I have the stock with the strategy I want to look at.
- Then on the left grid, I can enter in whichever option I want to look at. The option chain doesn't have any past expiration dates, but you can still pull up past expirations as long as you enter the long form option string name in the ticker box. I have a separate strategy on the option chart where I can just tell it what date and time to buy and sell, and it will tell me what the profit/loss would've been.

So all I have to do is just figure out when the strategy wanted to buy and sell the ATM option, and then manually input it into the option grid on the left. I can give the codes I'm using if anyone is interested.

It's not going to answer a question like "what is my profit if I buy an ATM call option when the price goes above premarket high over a 90 day period", but it does a pretty good job at isolated day trades. The only issue I'm seeing so far is that the Bid/Ask data is a bit spotty. But the midpoint price still works.

5nk36tj.png
 
Solution
Thanks Halcy. I found a workaround that works good enough for what I'm trying to do.
- I went to Trade -> All Products (it could probably also be done under the Analyze tab).
- On the Trade grid, I turned on 2 columns and as many rows as possible. Then shrunk all the bottom grids and expanded the top 2 as tall as they could go.
- On the right grid, I have the stock with the strategy I want to look at.
- Then on the left grid, I can enter in whichever option I want to look at. The option chain doesn't have any past expiration dates, but you can still pull up past expirations as long as you enter the long form option string name in the ticker box. I have a separate strategy on the option chart where I can just tell it what date and time to buy and sell, and it will tell me what the profit/loss would've been.

So all I have to do is just figure out when the strategy wanted to buy and sell the ATM option, and then manually input it into the option grid on the left. I can give the codes I'm using if anyone is interested.

It's not going to answer a question like "what is my profit if I buy an ATM call option when the price goes above premarket high over a 90 day period", but it does a pretty good job at isolated day trades. The only issue I'm seeing so far is that the Bid/Ask data is a bit spotty. But the midpoint price still works.

5nk36tj.png
Curious what your slope degree is.
 
How to get the ATM call price for the previous week open ? and will it extract the previous week date automatically, or there is no other way than manually type it -every week- ?
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
275 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top