The Options Trading Strategy based on MACD indicator

Hi all,

I want to share with you my options strategy using MACD. In this algorithm, When the MACD line crosses the slower signal line in the bullish direction, buy signal triggered.  When the MACD line crosses the signal line in the bearish direction, a covered call is written to reduced the downside risk. Usually, the covered call strategies will work well in steadily falling markets and not work in rapidly rising markets and range bound markets, depending upon the level of volatility.

Update Backtest

Jing this is a great example! Do you have an example using cyrpto and MACD? by any chance? or could you reference me to an algorithm example using cyrpto and one of the technical indicators? 


After getting the symbols list from OptionChainProvider, how do we get the bid/ask/last price of the options, the greeks and IV? I know we can get all these using SetFilter, but are they also available through OptionChainProvider? Thanks.


Hi Shawn, the manual filter OptionChainProvider will be limited to the information included in the Symbol(strike, expiration, type, style) without Greeks and IV. For underlying price, you can use self.Securities[underlying_symbol].Price.


Thanks Jing. Because of the wide bid/ask spread, it is almost always unfavorable to use market orders for options. That basically means the manual filter OptionChainProvider will not be useful in real trades. Are there any plans to at least add bid/ask/last option prices?


HI Shawn, yes we do need a way to easily get those prices for any symbol in OptionChainProvider without the overhead of a subscription and we are thinking about a solution for this very common request.


Okay, I have a pretty good understanding about call option from this site, but I want to know the code that you are using.

I am not an expert coder and I am familiar with a few of the basic languages and was wondering if someone could explain this code to me. I am just trying to learn a little bit here and there.

I want to know what are the parameters that need to be considered like the strike price and how does the algorithm factor in the risk involved with trading. Further, is it possible to set different strike prices for the same market in case the client requests to wait for a better price or something?

Kindly explain all of this to me!


Hi Jing Wu, I was trying to replicate your extremely good results above but I couldn’t. Then I realized your option bid prices were way too high (~5-7x more than expected: e.g. selling calls at $15 premium vs. more realist $2.2).

I added the following line in the ‘Initialize’ function (after “equity = “):


And everything started to make sense again. Unfortunately, but as expected, returns are much worse now.

Hope this may help anybody wondering about the above ‘too good to be true’ backtesting.


Sometimes I feel that more often than not, traders jump into the options game with little or no understanding of how many options strategies are available to limit their risk and maximize return. With a little bit of effort, however, traders can learn how to take advantage of the flexibility and full power of options as a trading vehicle. 

The advantage of trading options versus stocks is the use of leverage. You don’t need to invest as much money in order to participate in the movement of a stock, either up or down. Each option contract represents 100 shares of a stock and has an exercise and expiration date assigned to it. Most options expire within three, six or nine months. The strike price depends on the price of the underlying stock and varies as the stock price fluctuates. This proves similar for working capital loans. It can be lower or higher than the current market price of the stock.


Options are also helpful for implementing various trading strategies such as straddle, strangle, butterfly, collar etc. which can help in generating income for investors under various market conditions. The module which would be of interest to traders, investors, students and anyone interested in theoptions markets.

How to play MACD  oscillator main role in options trading stratege is mentioned below:

MACD is an oscillator, although it's often called a trend indicator or even a “trend oscillator”. It happens because MACD is based on two moving average indicators applied directly on the chart.


Hi Alex, thanks for the info. I've updated the attached algorithm and set the data normalization mode to be raw.


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed