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.


Staff member
Currently, the backtesting strategy only supports buying and selling of shares — no way to implement options into it.


Well-known member
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...


New member
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