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!