October 21

0 comments

A Modern Approach to Breakout Trading: The Better Breakout Strategy

By Jeff Swanson

October 21, 2024

Algorithmic Trading, day trading, EasyLanguage

Are you interested in an intraday breakout trading system that has been consistently performing since 2012? You're in the right place! In this article, we'll explore a modern approach to trading breakout systems, and I'll even share the code with you—for free.

Hello, I'm Jeff Swanson, and with over two decades of experience in the futures markets, I'm here to share my journey and help you become a successful algorithmic trader. This is the second article in our series on breakout trading strategies. If you missed the first article, you can read it here, The Powerful Benefits of Breakout Trading Systems.

Let's dive right in.

Understanding the Better Breakout Strategy

Today, we'll delve into a powerful breakout trading system specifically designed for the futures market. The strategy is called the Better Breakout, and it's tailored for the S&P E-Mini Futures market. The performance of this strategy has been impressive, showing strong results dating back to 1987.

The original rules for this strategy were described in Futures Truth magazine back in 2012, in an article titled "Better Breakouts in the Electronic Age" by Murray Ruggiero. While the magazine is no longer in circulation, I've written an article about it called Better Breakout Trading Model.  I wrote that article back in 2012 and that means we have 12 years of out-of-sample data!

The Shift in Breakout Strategies

Traditionally, many breakout strategies use the 8:30 AM Central Time opening as a key price level for determining when to enter long or short positions. However, with near 24-hour access to the futures market, the significance of that opening time has diminished.

Murray Ruggiero proposed a twist on the traditional breakout strategy. Instead of relying on the opening range, we're going to use yesterday's price action to set our breakout levels.

Who Was Murray Ruggiero?

Before we dive deeper, let's take a moment to acknowledge Murray Ruggiero's contributions.

Murray was a pioneering figure in algorithmic and quantitative trading, renowned for his expertise in advanced technologies like machine learning and intermarket analysis. He spent decades refining data-driven approaches and authored numerous articles and books that have been immensely helpful to traders, including myself.

Unfortunately, Murray passed away a couple of years ago, but his work continues to influence traders worldwide. He's perhaps best known for his insights into intermarket analysis and seasonality patterns. Thank you, Murray, for your invaluable contributions.

The Logic Behind the Better Breakout Strategy

Now, let's explore how Murray's strategy can help us improve a typical breakout system.

Using Yesterday's Price Action

Instead of relying on the traditional opening range, we'll use yesterday's price action to set our breakout levels. Let's consider yesterday's bar, which includes:

  • Open
  • High
  • Low
  • Close
Figure A: Yesterday's Price Action Bar

Figure A: Yesterday's Price Action Bar

We will use this information to build our breakout levels. Specifically, we'll calculate offsets based on the difference between yesterday's close and its high or low. The larger of these two values is averaged over three days to create a dynamic breakout range.

Calculating the Offsets

Here's how the process works:

Here's how the process works:

  1. Calculate the High Offset:
    High Offset=High−Close
  2. Calculate the Low Offset:
    Low Offset=Close−Low
Figure B: High and Low Offsets

Figure B: High and Low Offsets

These calculations are straightforward. We're essentially measuring the distance from the close to the high and the close to the low.

  1. Determine the Maximum Offset:
    • Take the larger of the two offsets.
    • For instance, if the close is near the high, the high offset will be small, and the low offset will be larger.
    • Store the larger value as the Max Offset.
  2. Compute the Three-Day Average:
    • Calculate the max offset for each of the last three days.
    • Compute the average of these three values.
    • Store this in a variable called Max Offset Average.

This approach gives us a more adaptive breakout level that reflects recent market conditions. It's less dependent on the arbitrary opening price and more aligned with current volatility. As market conditions change, our offset adapts accordingly.

The Logic Behind the Adaptation

By accounting for significant price movements from the previous day—both the highs and lows relative to the close—we create a breakout strategy that's responsive to the market's recent behavior. Smoothing out anomalies by averaging over three days ensures that our breakout levels aren't overly influenced by a single day's extreme movement.

Implementing the Strategy in EasyLanguage

Now, let's delve into how to implement the Better Breakout strategy using EasyLanguage in TradeStation. Don't worry if you're new to EasyLanguage; I'll break down each part of the code so it's easy to understand. Remember, mastering EasyLanguage is a crucial skill for becoming a successful algorithmic trader.

Input:
CloseTime(1500),
Lookback(40);

Variables:
LastBar(0),
StopLoss$(0),
vMomentum(0, Data2),
LowOffset(0, Data2),
HighOffset(0, Data2),
MaxOffset(0, Data2),
MaxOffsetAvg(0, Data2);

Once LastBar = CalcTime(CloseTime, -BarInterval);

LowOffset = AbsValue(Close of Data2 - Low of Data2);
HighOffset = AbsValue(Close of Data2 - High of Data2);
MaxOffset = MaxList(LowOffset, HighOffset);
MaxOffsetAvg = Round2Fraction(Average(MaxOffset, 3));
StopLoss$ = Round2Fraction(MaxOffsetAvg / 2) * BigPointValue;
vMomentum = Close of Data2 - Average(Close of Data2, Lookback);

If (vMomentum < 0) and (EntriesToday(Date) = 0) and (Time < LastBar) Then
Buy("LE") 1 Contract Next Bar at Close of Data2 + MaxOffsetAvg Stop;

If (Time >= LastBar) Then
Sell("EOD") Next Bar at Market;

SetStopLoss(StopLoss$);

Code Breakdown

Let's go through the code step by step to understand how each part contributes to the strategy.

Inputs

  • CloseTime(1500): This sets the time (in military format) when we want to close all positions. Here, it's set to 3:00 PM (1500 hours).
  • Lookback(40): This determines the number of periods (in this case, days) for calculating the momentum indicator

Variables

  • LastBar(0): Will store the time of the last bar before the close time.
  • StopLoss$(0): The calculated dollar amount for the stop loss.
  • vMomentum(0, Data2): The momentum indicator based on the daily chart (Data2).
  • LowOffset(0, Data2) and HighOffset(0, Data2): Variables to store the offsets from the close to the low and high of the previous day.
  • MaxOffset(0, Data2): The maximum of the two offsets.
  • MaxOffsetAvg(0, Data2): The three-day average of the maximum offset, rounded to the nearest valid price increment.

Calculate Last Bar Time

  • Purpose: Determines the time of the last bar before CloseTime.
  • CalcTime(CloseTime, -BarInterval): Calculates the time by subtracting the bar interval from the close time. This ensures we don't enter new trades too close to the market close.

Calculating the Offsets

  • LowOffset: The absolute value of the difference between yesterday's close and low.
  • HighOffset: The absolute value of the difference between yesterday's close and high.
  • Data Reference: Data2 refers to the daily data series we've added to our chart. This allows us to access daily high, low, and close prices while trading on a 5-minute chart (Data1).

Determining the Maximum Offset and Average

  • MaxOffset: Selects the larger of the two offsets for each day.
  • Average(MaxOffset, 3): Calculates the average of the maximum offsets over the last three days.
  • Round2Fraction(...): Rounds the average to the nearest valid price increment (tick size), ensuring our calculations align with the market's price increments.

Calculating the Dynamic Stop Loss

  • Purpose: Sets a dynamic stop loss based on recent market volatility.
  • MaxOffsetAvg / 2: We take half of the average maximum offset to determine a reasonable stop distance.
  • BigPointValue: A built-in variable representing the dollar value of a full point move in the contract (e.g., $50 for the ES futures).
  • StopLoss$: The stop loss value in dollars, adjusted to market increments.

Calculating the Momentum Filter

  • Purpose: Measures market momentum to filter trades.
  • Close of Data2: The closing price from the daily data series.
  • Average(Close of Data2, Lookback): The 40-day simple moving average of the close.
  • vMomentum: When this value is negative, it indicates that the current price is below the 40-day moving average, suggesting a potential buying opportunity in a pullback.

Entry Conditions

  • (vMomentum < 0): Ensures we're only entering trades when the momentum indicator is negative (price below the moving average).
  • (EntriesToday(Date) = 0): Limits us to one trade per day.
  • (Time < LastBar): Prevents new entries too close to the market close.
  • Buy("LE") 1 Contract Next Bar at Close of Data2 + MaxOffsetAvg Stop;:
    • Action: Places a stop order to buy one contract.
    • Price Level: At yesterday's close plus the average maximum offset.
    • Order Name: "LE" (Long Entry).

Exit Conditions

  • (Time >= LastBar): Checks if we've reached the time to close positions.
  • Sell("EOD") Next Bar at Market;:
    • Action: Sells the position at the market price on the next bar.
    • Order Name: "EOD" (End of Day)

Setting the Stop Loss

  • Purpose: Implements the stop loss calculated earlier.
  • Dynamic Stop Loss: Because StopLoss$ is based on recent volatility, it adapts to changing market conditions.

By understanding each component of the code, you can see how the Better Breakout strategy uses recent price action and market momentum to determine entry and exit points. The use of dynamic calculations makes the strategy adaptive to changing market conditions, which is crucial for long-term success in algorithmic trading.

If you're new to EasyLanguage, I highly recommend taking the time to learn it. The best way to do that is to have me teach you in my System Development Master Class.  Being able to code and test your own strategies is an invaluable skill that can significantly enhance your trading performance.

Setting Up the Chart in TradeStation

To implement this strategy in TradeStation:

Chart Settings:

  • Session Times: 8:30 AM to 3:00 PM Central Time.
  • Time Frame: 5-minute chart.
  • Slippage and Commissions: $30 deducted per round trip.
  • Data Stream:
    • Data1: 5-minute chart (trading timeframe).
    • Data2: Daily chart (for calculations).

Trading Rules:

  • Long Only: The strategy is designed for long entries.
  • One Trade Per Day: Ensures risk management and prevents overtrading.
  • Close All Trades at End of Day: All positions are closed at the specified close time.

Performance Analysis

The equity curve shows a steady upward trend since 2012, indicating consistent performance. While there has been some choppiness in recent times, the strategy has maintained its profitability

Better Breakout 2024

Better Breakout 2024

Key Performance Metrics:

  • Total Net Profit: Approximately $35,000.
  • Average Trade Profit: $181 (including slippage and commissions).
  • Total Trades: 191.

Annual Returns Breakdown:

  • Profitable in most years since 2012.
  • Notable exceptions in 2013 and potentially 2024.

Trying the Strategy on Different Markets

One of the great aspects of algorithmic trading is the ability to test strategies on different markets. Let's see how the Better Breakout strategy performs on the NASDAQ futures (NQ).

A New Market and New Chart Setting

In an effort to explore the robustness and adaptability of the Better Breakout strategy, I decided to apply it to the NASDAQ futures (NQ) market. The NASDAQ futures often exhibit higher volatility and different trading dynamics compared to the S&P E-Mini Futures (ES), which can potentially enhance the strategy's performance.

Next I adjusting Data2 to use a 1,440-minute chart (equivalent to a daily chart), we can test the strategy on the NASDAQ futures.

The 1,440-minute chart provides more accurate pricing information because the closing price represents the actual last traded price, rather than the settlement price used in daily bars. Settlement prices can introduce inaccuracies due to adjustments made at the end of the trading day, which can affect real-time trading strategies. By using the last traded price, we eliminate issues with changing settlement prices, leading to more precise entry and exit signals.

Using a 1,440-minute chart leads to more accurate backtesting results. It removes discrepancies between daily Open, High, Low, and Close (OHLC) prices and minute bar OHLC prices that can significantly impact backtested strategy performance. 

Better Breakout on NQ with 1440 minute data2  2012 to 2024-10-09

Better Breakout on NQ with 1440 minute data2 

Improved Performance Metrics:

  • Total Net Profit: Approximately $60,000.
  • Average Trade Profit: $308.
  • Total Trades: 193.

The equity curve for NQ shows an even more impressive upward trend, with a new equity high as recent as August 2024

Experimenting with the Momentum Filter

In the original Better Breakout strategy code, we included a momentum filter to improve the quality of our trade signals. This filter is designed to ensure that we only enter trades when certain momentum conditions are met, potentially increasing the efficiency and profitability of the strategy.

I also experimented with removing the momentum filter to see its impact.

Without Momentum Filter:

  • Total Net Profit: Approximately $67,800.
  • Average Trade Profit: $108.
  • Total Trades: 627.
  • Profit Factor: 1.63.
  • Equity Curve: More volatile with a larger number of trades and lower efficiency.

With Momentum Filter:

  • Total Net Profit: Approximately $60,000.
  • Average Trade Profit: $308.
  • Total Trades: 193.
  • Profit Factor: 1.88.
  • Equity Curve: Smooth upward trend with fewer trades and higher efficiency.

By only allowing trades when the price is below the 40-day moving average, the filter reduces the number of trades. It helps us focus on higher-probability setups where the market may be poised for a rebound after a pullback.

This illustrates the importance of testing different ideas. Removing the momentum filter increased the number of trades and total profit but reduced efficiency. Depending on your trading goals, you might prefer one setup over the other.

Avoiding Rookie Mistakes

When experimenting with algorithmic trading, keep these common pitfalls in mind:

  1. Not Trying Different Markets:
    • Don't limit yourself to a single market. Testing on similar markets can yield better results, as we saw when switching from ES to NQ.
  2. Not Trying Different Time Frames:
    • Experiment with different time frames, both for your trading chart and data inputs. Small changes can lead to significant differences in performance.

Conclusion

In this article, we've explored the Better Breakout strategy, a robust and adaptive approach to intraday breakout trading that has stood the test of time since its inception in 2012.

The Better Breakout strategy continues to demonstrate its effectiveness in today's markets, proving to be a reliable and adaptable approach for algorithmic traders. Its strength lies in its simplicity and the use of dynamic calculations that adjust to changing market conditions. Whether you're a novice trader or an experienced professional, this strategy offers a solid foundation upon which you can build and customize your own trading system.

By understanding the underlying logic and experimenting with different time frames, and filters—you can tailor the strategy to fit your trading style and objectives. I think the Better Breakout only works well for the stock index markets, but it's worth testing other markets. 

Final Thoughts

Algorithmic trading is a journey of continuous learning and adaptation. The Better Breakout strategy serves as an excellent starting point, encouraging you to delve deeper into the mechanics of trading systems and the nuances of market behavior. As you apply and modify this strategy, you'll gain valuable insights and develop the skills necessary to become a successful algorithmic trader.

Remember, the key to success lies in diligent testing, thoughtful analysis, and a willingness to experiment. Don't hesitate to explore different markets, adjust parameters, and incorporate new ideas. The more you engage with the strategy, the more proficient you'll become in crafting systems that align with your goals.


Jeff Swanson

About the author

Jeff has built and traded automated trading systems for the futures markets since 2008. He is the creator of the online courses System Development Master Class and Alpha Compass. Jeff is also the founder of EasyLanguage Mastery - a website and mission to empower the EasyLanguage trader with the proper knowledge and tools to become a profitable trader.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn To Code & Build Strategies
Using EasyLanguage. 

>