MACD cross-over doesn't work on Streaks?

I have the following strategy:

Entry conditions:

  1. MACD crosses above the signal (macd(12,26,9,macd,0) crosses over macd(12,26,9,signal,0))
  2. MACD histogram value less than 0 (macd(12,26,9,histogram,0) lower than 0.0)
  3. CMP is higher than 200EMA (Close(0) higher than EMA(close,200,0)

This strategy was back-tested for MIS from 18.06.2020 to 18.06.2021 for SAIL, ONGC, and GAIL with 5m and 15m frequency. Back-test did not produce even one signal. I could identify quite a few manually though. What is wrong with the code?

Refer to this example for SAIL:



@Streak can you.

Hi @MangalaSV ,

MACD histogram is calculated as the difference of MACD and MACD Signal (blue line - orange line).
So when Macd crosses above Macd signal, so macd is higher than macd signal, so at that moment Macd histogram cannot be less than 0.

You have marked one candle before the cross-over(and that’s why your think histogram is lower than 0), once cross-over happens in the next candle(once you zoom in, you will see), at that moment Macd histogram has become higher than 0.

Macd histogram is just used to visualize the difference between MACD and MACD histogram.
If you just remove the histogram condition you will see the trades, or even if you change the offset in histogram to -1 then also you will see the trade in the backtest.

Hope this helps!

1 Like

Sure thanks a lot that helped.
@Streak Is there any preconditions to set start and end date for backtesting? As I enter the end date, the start date automatically set to only 3-months. I need to test for 1 year.

A new strategy to work on streaks. Have to try to see how this MACD crossover works on streaks. Thanks for the entry conditions.

Hi @MangalaSV,

There is a limit on the amount of data you can backtest at a time. For example, a maximum of 3 months backtest is allowed of 5min timeframe. You will find the details here

You can, however, test on older dates by changing the backtest start and stop date from the Advanced section in the create strategy page and testing them in tranches.

You can follow the condition mentioned here