Strategies for backtesting basic option plays


New member
Hi guys,
I'm trying to find, if it exist, a backtest strategy for purchasing (iron butterflies, straddles, etc) weekly, monthly and hold til expiration. Didn't think it would be difficult, but haven't found any in TOS. Guidance would be appreciated. Hoping not to recreate the wheel here.
Currently, the backtesting strategy only supports buying and selling of shares — no way to implement options into it.

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

You can backtest options, singularly, the same way you test other Equities... The problem is that you can't backtest combination strategies... I have run literally hundreds of backtests on options as they are what I primarily trade...
Hello Everyone,

I am trying to come up with a strategy to backtest buying at-the-money options. I have tried searching for similar threads but have not been able to find a solution. To explain the strat, I want the strategy to buy an ATM call option when the 9 EMA crosses above the 12 EMA and close it when the 5 EMA closes below the 12 EMA. I am testing this currently on the SPY on the 4HR time frame.

I started looking into GetATMOption() but am not sure how to get this to work with the AddOrder(); function. I want to use this function to see what the PL would be when applying this strategy.

Here is the script I currently have,

def EMA5 = ExpAverage (close, 5);
def EMA9 = ExpAverage (close, 9);
def EMA12 = ExpAverage (close, 12);
plot Long =
EMA9 crosses above EMA12;
plot Short =
EMA5 crosses below EMA12;
AddOrder(OrderType.BUY_TO_OPEN, condition = Long, price = close, 1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");
AddOrder(OrderType.SELL_TO_CLOSE, condition = Short, price = close, 1, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");

I would greatly appreciate any help or guidance in the right direction.

Thank you!

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
441 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.