One day I had the need to make a custom indicator and have it work on the underlying and on it's option contracts, I had no idea how to do it, so I threw some stuff together and ended up with this.

The whole point of it is that we cannot subscribe to an option contract symbols because the atm symbol changes and will expire at some point. We want a seamless update of quotebars of whatever timeframe. That is why we manually update the indicator this way. I left it to calls only for the sake of simplicity and just a simple moving average cross to give you guys this framework. I also made the “updateIndicators” function for ease of use if we ever want to trade multiple symbols. If anyone finds a way to use a for loop for this let me know I'd like that.

Hope you guys enjoy, let me know any bugs or changes you see!

 

P.S. I added the Plot part after I recorded my YT video it is in this backtest though.

 

Check out my YouTube to see more videos like this: