Exploring the Power of Alternating Body Color Pattern: Backtesting and Automation with NinjaTrader 8

Introduction

At TradingDJ, our primary focus is on automating trading strategies to streamline and enhance trading performance. Recently, I revisited a fascinating and simple trading pattern known as the Alternating Body Color pattern. This strategy, which signals trades based on the alternating colors of candlesticks, holds significant promise for traders. In this blog post, I'll share my journey of creating, testing, and automating this strategy using NinjaTrader 8.

The Genesis of the Strategy

The Alternating Body Color pattern is straightforward yet powerful: a green candlestick followed by a red one signals a sell, and a red candlestick followed by a green one signals a buy.

The arrows show the signal on the chart

Although I had known about this pattern for a long time, I initially dismissed it as too simple and in need of more filters. However, I recently incorporated this pattern into a trading game on my website, TradingDJ (https://game.tradingdj.com), to see how it performs in a simulated environment. I created this game to see how the context influences the outcome, and to build my intuition while playing. I wanted a very simple setup because my focus was the context.

TradingDJ game. try it out at game.tradingdj.com

Initial Observations

As I engaged with the TradingDJ game, I noticed an encouraging trend: even when taking all trades based on the Alternating Body Color pattern, the overall results were positive. However, the performance significantly improved when I applied filters to select trades more selectively. This observation sparked the idea of automating this strategy using NinjaTrader 8, specifically on the ES 5-minute chart.

Automation with NinjaTrader 8

With the promising results from the TradingDJ game in mind, I decided to automate the Alternating Body Color strategy in NinjaTrader 8. The goal was to validate its effectiveness in a backtesting environment and potentially refine it for real-time trading.

Backtest Results

Initially, I ran backtests on the combined strategy, which included both long and short trades. The results showed a mixed performance:

Next, I tested the strategy separately for long trades and short trades to see if the performance would improve by isolating the trade directions. Surprisingly, the results remained consistent, indicating that the strategy's overall performance did not significantly benefit from isolating trade directions.

Long Trades:

Long only

Short Trades:

Short only

Challenges and Insights

One of the key challenges observed was the discrepancy between the manual trading results from the TradingDJ game and the automated backtest results in NinjaTrader 8. In the TradingDJ game, the results are expressed in R, representing the risk taken per trade. For instance, if the R is 1% of the account, then 50R means 50% of the account. In contrast, the automated strategy in NinjaTrader used a fixed contract size.

I initially expected the winning percentages to remain similar between the game and the backtest. However, the results were quite different. The main reason for this discrepancy is the way NinjaTrader handles trades: it does not take new trades until the current one is closed. This limitation significantly impacts the strategy's performance, highlighting the need for further refinement.

Additionally, testing only long or only short trades to increase the number of trades did not improve the results. This suggests that the strategy may require more sophisticated filters or conditions to enhance performance.

Future Directions

The initial backtest results, while not as promising as expected, provide valuable insights for improvement. Moving forward, I plan to refine the strategy by introducing additional filters and adjustments. These enhancements aim to align the automated performance more closely with the promising manual trading results observed in the TradingDJ game.

Some potential filters to consider include:

  • Volatility Filters: Ensuring trades are taken only during periods of sufficient market movement.
  • Trend Confirmation: Combining with trend indicators to validate the direction of trades.
  • Time Filters: Restricting trades to certain times of the day when the market is more active.

Encouragement to Stay Tuned

This journey of exploring and automating the Alternating Body Color pattern is just beginning. I am committed to developing more refined versions of this strategy and sharing the results with you. Stay tuned to the TradingDJ blog for updates on new tests and improvements.

Conclusion

The Alternating Body Color pattern, despite its simplicity, holds significant potential for automated trading strategies. My initial experiments and backtests have provided valuable insights, paving the way for future refinements. I invite you to join me on this journey as we continue to explore and enhance this strategy.

Join the TradingDJ Community

I encourage you to try out the TradingDJ game and share your feedback on this pattern. Subscribe to the TradingDJ blog and become part of our community to stay informed about new strategies and updates. Together, let's uncover the full potential of automated trading strategies.