This script provides a solid foundation for backtesting the Positional MACD Crossover Strategy in TradingView. We have already discussed the strategy in the last chapter.
In Tradingview, You can find the NIFTY futures in a continous contact which means it will auto rollver when there is expiry and it will take the prive of the contact whcih is about to expire. So that is exaclty what we need.
So although the lot size and margin changes over time, we have taken the contract to be 1 which mean it will take the 1 lot automatically. The current margin of 1 lot nifty is around 1,50,000 inr. So, Lets run the strategy with various timeframe to analsyse how it is working.
The reason of choosing NIFTY straightforward because it is an index.
For the 15-minute timeframe, the strategy executed a total of 1503 trades, with a net profit of 318,485.00 INR and a profit factor of 1.117.
Moving to the 30-minute timeframe, there were 915 trades, a notable decrease, but with an increased net profit of 354,005.00 INR.
For the 1-hour timeframe, the number of trades fell further to 485, yet the net profit climbed to 353,705.00 INR, and the percent profitable trades stood at 38.97%.
The 1-day timeframe backtest of the MACD crossover strategy on Nifty Futures shows that out of 291 total closed trades, the strategy produced a net profit of 70,880.00 INR, which is a 47.25% return on the initial amount.
For the 1-week timeframe, the strategy executed 62 trades, yielding a net profit of 203,295.00 INR, which is a substantial 135.53% return.
In the 1-month timeframe, the strategy executed just 16 trades.
After closely examining the MACD crossover strategy applied to Nifty Futures over various timeframes, we observe a clear pattern in performance.
Starting with a 15-minute window, where trade frequency is high but profits per trade are smaller, we move to a 30-minute timeframe, which, despite fewer trades, shows improved net profits. As we expand our lens to an hourly scale, the trade count drops but profits remain consistent, with risk seeming more controlled.
The daily scale brings a balance, with fewer trades and moderate profits, though the risk, as indicated by the maximum drawdown, is still notable. Stepping up to a weekly view, we encounter a significant return rate with the trade-off of the lowest win rate and a high-risk profile.
Lastly, the monthly strategy presents a cautionary tale: with very few trades, it results in substantial losses, suggesting infrequency can be as much a bane as a boon.
In simple terms, the shorter 30-minute strategy seems to hit the sweet spot between managing risk and earning a profit, while the longer monthly timeframe, despite its high potential, carries too much risk due to its low number of trades.
As we see, the longer the timeframe, the more the strategy’s risk increases, which is something to keep in mind for those looking to dip their toes in trading waters.
So far, it is a blockbuster and simple strategy that works!