EasyLanguage – Helping you Master EasyLanguage https://easylanguagemastery.com Helping you Master EasyLanguage Thu, 16 Jan 2025 12:50:04 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.2 https://easylanguagemastery.com/wp-content/uploads/2019/02/cropped-logo_size_icon_invert.jpg EasyLanguage – Helping you Master EasyLanguage https://easylanguagemastery.com 32 32 Is The Christmas Season Bullish For U.S. Markets? https://easylanguagemastery.com/market-studies/christmas-trade/?utm_source=rss&utm_medium=rss&utm_campaign=christmas-trade https://easylanguagemastery.com/market-studies/christmas-trade/#comments Mon, 16 Dec 2024 11:00:00 +0000 http://systemtradersuccess.com/?p=2821

With the Christmas season upon us, I thought it would be interesting to review how the S&P behaves in the days just before Christmas. Do the days just before this holiday tend to be bullish, bearish, or neutral?

To test the market behavior just before the Christmas holiday I will use the S&P Cash index back in 1960. I will create an EasyLanguage strategy that will enter a trade X days before Christmas and close that trade on the opening of the first trading day after Christmas. Each trade will dedicate $100,000 to purchase shares. Stops, and both commissions and slippage are not utilized in this study.

Ten Days Before Christmas

First let's look at the 10 days before Christmas. What happens if we enter a trade X days before Christmas and close that trade on the open after Christmas? By using TradeStation's optimize feature I can systematically test each day over the historical data. The results of each test is the generated P&L for each iteration and is depicted in the bar graph below. Looking at the graph, each bar on the x-axis represents the number of days before Christmas.

It appears that the 10 days before Christmas all show positive P&L. In general, the longer you're holding period before Christmas the better.

Ten Days After Christmas

Using a similar trading system, I will look at entering a trade on open of trading day following Christmas and holding that trade for X days. Below is a bar graph showing the days 1-10 after Christmas. Again, each bar represents P&L and the x-axis is the number of days the trade is held.

Historically, all days after Christmas in our study have returned positive results. Unlike the 10 days before Christmas, in this case it appears there is not much gain for holding beyond five days.

The Christmas Trade

Based on the information above, which seems to show a strong bullish biased for the days immediately before and after Christmas, I'm going to create another strategy that will open a trade five days before Christmas and closes that trade five days after Christmas. I picked five days simply because it was the middle value (1-10) for the days before and after Christmas we tested. Last year's Christmas Trade (December 2022) was a losing trade. It's pictured below.

Christmas Trade 2023

Christmas Trade 2023

When you combine all the trades going back to 1960 we get the following equity curve and performance, below. The last equity peek was in 2021.

Christmas Trade Equity Curve

Conclusion

There certainly does seem to be a very strong bullish tendency around Christmas. The most recent action looks a little more flat. However, we did have a new equity high in 2021.

Can you take advantage of this in your trading? Perhaps. Remember, the code with this article is not a complete trading system, but an indicator to help me gauge the market behavior around the Christmas holiday. If you have trading systems or trade a discretionary method around these days before and after Christmas, you might use this knowledge to ignore short signals, or modify your exit based upon what we learned. 

]]>
https://easylanguagemastery.com/market-studies/christmas-trade/feed/ 5
Adapting to Volatility: Strategic Position Sizing for Algorithmic Traders https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/?utm_source=rss&utm_medium=rss&utm_campaign=percent-risk-and-volatility-2 https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/#comments Mon, 02 Dec 2024 11:00:18 +0000 http://systemtradersuccess.com/?p=2748

I’m going to show you how to turn a good system into an amazing system with just a few lines of code! Adding these few lines of code could make you an additional $10k, $25K or even $50K in profits instantly.

Today we’re going to take my Better Breakout Strategy, which is a day trading strategy and dramatically improve it’s ability to generate profit. The simple technique I’m going to show you can easily be applied to any of your trading systems allowing you to generate 10s of thousands of more dollars quickly.

Let’s start with a thought experiment.

Explain This Mystery?

Say we have two traders who are each given identical trading systems to execute on the NASDAQ futures market (@NQ).  Because both systems are identical copies of an automated trading system, both trading systems generate the same buy/sell signals, use identical stop loss and trailing stop parameters.

These two traders are also going to start trading on the same day, with the same starting account size.  In essence let’s pretend we have two traders that have identical trading circumstances. Let's give these two traders 12 months to trade.  At the end of the trading period, we would expect them to have the same account balance, right?

But at the end of the trading period, reality has made fools of us. One trader generated more net profit. How can this be?

Reviewing the trading results for both traders you can see both traders took the same signals. Both traders have the same win/loss ratio and even the same number of stop-out trades. But there is one difference.

One trader used a simple mathematical formula to determine how many shares to buy and thus, his account grew at a faster rate.

What is Position Sizing

Position sizing is a critical component of both systematic and discretionary trading, addressing the pivotal question: How many shares or contracts should I purchase?

Far too often, the answer is derived from nothing more than a well-informed guess. A common misstep among traders is to size their trades without considering risk, potentially undermining their results, their trading systems, and, in some cases, their careers as algorithmic traders!

By anchoring your trade size to a risk metric, you adopt a defensive stance against the unpredictability of the market. Risk management should be paramount for any trader aiming for long-term success. Therefore, employing a risk-based metric to mathematically size your trades is not just recommended; it's essential. Despite this, the common practice involves using a fixed number of shares or allocating a fixed dollar amount per trade. Let's pause to consider the implications.

Imagine your trading system signals a new buy opportunity. You could, theoretically, risk your entire cash balance on this single signal. A win might double your money swiftly, but a loss could deplete your account entirely. It's evident that staking your whole account on one trade is a gamble far too risky for any prudent investor. This extreme example illustrates a fundamental truth: risking your entire trading capital on a single trade is recklessly imprudent.

So, what's the prudent amount to wager? Maybe 90% of your account? Or perhaps you decide on purchasing 100 shares. Many system developers overlook how trade size influences the risk-reward dynamic of a trade.

As the risk increases, so does the potential reward. Yet, overextend your risk, and a few losing trades could decimate your account. Theoretically, there's an optimal balance between risk and reward specific to each trading system.

Your mission is to identify a nearly optimal level that aligns with your comfort as a trader. While delving into the intricacies of finding an optimal position sizing strategy for a specific trading system is beyond the scope of this discussion, I will illustrate the difference between employing a risk-based position sizing algorithm and simply buying a fixed number of shares—the latter being a common practice that neglects risk metrics, thereby failing to adjust trade sizes according to market conditions.

Does a risk-based approach truly offer an advantage? Let's delve into the evidence.

Our Day Trading Algorithm

We will be using a simple intraday breakout model called, Better Breakout which was discussed in thie article, A Modern Approach To Breakout Trading. Please review that article for the strategy rules. The code is available for all EasyLanguage Mastery subscribers.

Let's load the strategy on a NASDAQ Futures (@NQ) chart.

  • Historical data January 1, 2012 through October 31, 2024
  • Trades are executed on a 5-minute bar
  • All trades are closed at the end of the day
  • A dynamic stop loss based upon the volatility of the market. See the code for details.
  • All trades are long only.
  • We assumed a starting capital of $100,000
  • $15 for slippage and commissions deducted for each round trip.

Below is an example of the strategy trading on the daily chart of @NQ. We can see the trade entering early on the 9:05 AM bar on a big gap up from the previous day. The trade closed at 15:00 PM the same day.

Fixed Contract Position Sizing

The fixed-share method is a non-risk-based method. In this case we simply buy the same number of contracts (1) for each signal. I use this technique all the time when developing a strategy. But it's probably not the best way to trade something live.

Contracts = 1


Percent Risk Position Sizing

The percent-risk method is a strategy grounded in risk management. In this approach, we allocate a fixed percentage of our equity—2% in this example—to risk on each trading signal. The choice of 2% is guided by a widely accepted principle in trading that suggests risking anywhere from 0.5% to 2% of your account balance on any single trade. This strategy aims to mitigate the impact of a series of losses, preventing them from significantly damaging your trading account. We then use this predetermined risk percentage to calculate the specific dollar amount you're willing to risk on an individual trade.

Example:

Contracts  = (2% of Account Equity) / ( Stop Loss Per Contract)
Contracts  = (2% * $100,000)/ $500
Contracts = $2,000 / $500
Contracts = 4

In the example provided, we have the methodology to calculate the number of contracts to purchase while maintaining a consistent risk level of 2% of the account size per trade. As mentioned, the stop-loss value for the 'Better Breakout' strategy adjusts based on recent market volatility, as detailed in the original article.

This adaptive approach means that if market volatility increases, our stop-loss threshold will widen. Consequently, to adhere to our 2% risk per trade guideline, we might find ourselves buying fewer contracts. Conversely, in periods of reduced volatility, our stop-loss tightens, allowing us to purchase more contracts without breaching the 2% risk rule.

The essence of this strategy is that we never risk more than 2% of our account on a single trade. This flexibility enables us to adjust the number of contracts traded in response to the volatility of the market, effectively normalizing our risk exposure relative to market conditions.

But what implications does this have for our trading outcomes?

Performance Comparison

Fixed

2% Risk

Net Profit

$59,595

$112,350

Profit Factor

1.88

2.16

Total Traders

193

193

Avg.Trade Net Profit

$308.78

$582.12

Annual Rate of Return

3.64%

5.87%

Max Drawdown (Intraday)

$10,425

$13,270

NP vs DD

5.7

8.5

In our analysis, we observed an increase in profits while maintaining the same number of trades (almost, there is one extra trade), without escalating our maximum intraday drawdown. We also increased every other metric!. 

This is a clear win. More profit. Identical risk. 

It's important to note that in our Percent Risk model, we are not reinvesting profits. We started trading with an account balance of $100,000 which remains constant for the purpose of calculating position sizes.

Why adopt this approach?

The goal was to evaluate the impact of scaling trades based on market volatility and to compare its performance with that of the Fixed Model. Incorporating profits into our calculations would undoubtedly enhance our returns further. However, I preferred to avoid complicating the analysis with additional variables. This decision was made to provide a clearer comparison and to focus solely on the influence of the position sizing model.

Pitfalls To Avoid

Don't Using Position Sizing To Improve A Poor System

First, let’s tackle a common misconception: thinking position sizing can turn a mediocre system into a winner.

Here’s the truth – position sizing isn’t a magic fix. If your trading system doesn’t have a solid foundation, even the best position sizing approach won’t make it profitable in the long run.

Imagine trying to fix a car with no engine by just repainting it; it might look better, but it’s still not going anywhere. You should always start with a positive expectancy system, meaning it’s capable of generating returns based on the market behavior it was designed to exploit.

Think of position sizing as the tool that can amplify or protect your returns, not create them from scratch. So, before diving into advanced sizing techniques, ensure your system is already well-tuned and thoroughly backtested. Only then can you expect position sizing to help elevate your results.

Don’t Risk Too Much Per Trade

Now, here’s a mistake that every beginner should be wary of risking too much per trade. It’s easy to think that a higher risk per trade means faster growth, but the opposite is true – the more you risk, the faster you can blow up your account.

In professional trading, a common rule is to keep risk per trade around 1-2% of your account. Why? Because this allows you to survive the inevitable losing streaks. Even the best trading systems will experience losses, sometimes back-to-back.

If you’re risking 5%, 10%, or more on a single trade, it won’t take long for a few bad trades to wipe out a significant portion of your capital. Here’s the bottom line: keeping your risk per trade at around 2% or lower gives you the breathing room to recover from losses and make adjustments if needed. It’s all about protecting your account so you can stay in the game for the long haul.

Remember, in trading, slow and steady does win the race.

Conclusion

Alright, let’s recap the main points.

We started with the concept of position sizing and why it’s essential for traders who want consistent, long-term results. We saw how adjusting trade size based on a percent-risk approach – rather than a fixed contract method – can help align your trades with market conditions, providing flexibility and stability in a volatile environment.

We also dug into the two common pitfalls to avoid: first, don’t rely on position sizing to make up for a weak system. Build a solid foundation with a proven strategy, and then let position sizing enhance it. Second, keep your risk per trade at a reasonable level, around 2%, to avoid those devastating losses that can sideline even the most promising traders.

Key takeaway? Strategic position sizing is a powerful tool when used with a robust trading system and disciplined risk management. It’s about managing your exposure, protecting your capital, and allowing your account to grow consistently.

Good luck with your trading.

]]>
https://easylanguagemastery.com/building-strategies/percent-risk-and-volatility-2/feed/ 5
A Modern Approach to Breakout Trading: The Better Breakout Strategy https://easylanguagemastery.com/strategies/a-modern-approach-to-breakout-trading-the-better-breakout-strategy/?utm_source=rss&utm_medium=rss&utm_campaign=a-modern-approach-to-breakout-trading-the-better-breakout-strategy https://easylanguagemastery.com/strategies/a-modern-approach-to-breakout-trading-the-better-breakout-strategy/#comments Mon, 21 Oct 2024 10:00:00 +0000 https://easylanguagemastery.com/?p=535126

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.


]]>
https://easylanguagemastery.com/strategies/a-modern-approach-to-breakout-trading-the-better-breakout-strategy/feed/ 2
The Powerful Benefits of Breakout Trading Systems https://easylanguagemastery.com/getting-started/the-powerful-benefits-of-breakout-trading-systems/?utm_source=rss&utm_medium=rss&utm_campaign=the-powerful-benefits-of-breakout-trading-systems https://easylanguagemastery.com/getting-started/the-powerful-benefits-of-breakout-trading-systems/#respond Mon, 07 Oct 2024 10:00:00 +0000 https://easylanguagemastery.com/?p=535069

Looking to elevate your trading with strategies that have stood the test of time? 

In this article, we’ll dive deep into breakout trading strategies and explore the key benefits they can bring to your trading approach. From reducing risk to adapting to different market conditions, breakout strategies are momentum-based, meaning we’re buying into strength.

Let's get started!

Understanding Breakout Strategies

Breakout strategies are momentum strategies, which means we're buying into strength as the market moves upward. By capitalizing on significant price movements, these strategies aim to enter trades at the onset of a trend.

Examples of Breakout Strategies

  • New 52-Week High: Buying a stock when it makes a new 52-week high is a common approach.
  • New 10-Day High: Purchasing when a stock hits a new 10-day high can signal emerging momentum.
  • Price Crossing Above a Moving Average: Buying when the price crosses above a moving average indicates a potential upward trend.

Consider an example of three consecutive higher closes:

  1. Close 1: The close is above the previous bar
  2. Close 2: The close is again above the previous bar.
  3. Close 3: The close continues to rise above the previous bar.

This sequence serves as our buy signal. We're aiming to ride the trend, assuming the price is breaking out to a new high, and hoping the market continues to move in our direction.

The Five Key Benefits of Breakout Trading Strategies

Now that we understand what breakout strategies are, let's explore the key benefits they offer to enhance your trading performance:

1. Reduced Market Exposure

Breakout strategies are ideal for day trading, allowing you to enter and exit positions within the same day. This approach minimizes the risk of overnight gaps and unexpected news events that can cause significant price swings when the market is closed. By focusing on intraday movements, you limit your exposure to unpredictable events, making it a safer strategy for many traders.

2. Adaptability

Another significant advantage is their adaptability. Breakout strategies can be adjusted to suit current market conditions, and many have built-in parameters that automatically adapt to market volatility. This flexibility makes them robust across different market environments, which is essential for consistent performance.

3. A Proven Track Record

Breakout strategies have been around for decades—and for good reason: they work. Tested and refined in countless market conditions, they boast a proven track record of success. Building on this solid foundation gives you confidence, knowing you're not starting from scratch but leveraging strategies that have stood the test of time.

4. Scalability

These strategies aren't limited to just one market. They can be applied across multiple markets—stocks, futures, forex, or even cryptocurrency—and various timeframes. This versatility allows you to diversify your portfolio, spread risk, and capture opportunities in different asset classes. The fact that breakout strategies work across different markets and timeframes underscores their effectiveness—they simply work.

5. Ideal for Beginners

Finally, breakout strategies are excellent for beginners. If you're a new trader—not yet making money consistently—why reinvent the wheel? Breakout trading is a smart choice, providing a straightforward and effective approach. I always recommend that both new and seasoned traders consider incorporating breakout strategies into their trading arsenal.

Implementing Breakout Strategies with EasyLanguage

Now that we've explored the benefits, let's look at how to implement a breakout strategy using TradeStation and EasyLanguage.

20-Day Price Channel on NASDAQ Futures Chart

In TradeStation, we're examining the daily chart of the NASDAQ futures. I've applied a simple indicator—a 20-day price channel:

  • The green line represents the 20-day highest high.

  • The red line represents the 20-day lowest low.

We're looking for a breakout when the price closes above this 20-day high. When this happens, we initiate a long position, aiming to catch a momentum trade and capture some profit. The red line signifies our exit—we hold the position until the price closes below the 20-day low.

Writing the EasyLanguage Code

Here's how to implement this strategy in EasyLanguage:

Inputs:
breakout(20);
Variables:
hiBreakout(0),
loBreakout(0);

hiBreakout = Highest(High, breakout)[1];
loBreakout = Lowest(Low, breakout)[1];

If Close > hiBreakout Then
   Buy Next Bar at Market;
If Close < loBreakout Then
   Sell Next Bar at Market;

Breaking Down the Code:

Inputs: We define the breakout range (breakout) as 20 days.

Variables: We calculate the highest high (hiBreakout) and the lowest low (loBreakout) over the breakout range.

  • hiBreakout = Highest(High, breakout)[1]; tells TradeStation to look at the highest high starting from the previous bar ([1]) over the past 20 days.
  • loBreakout = Lowest(Low, breakout)[1]; does the same for the lowest low.

Trading Logic:

  • Buy Signal: We buy when the closing price is greater than the high breakout.
  • Sell Signal: We sell when the closing price is less than the low breakout.

Applying the Strategy

When we apply this strategy to our chart:

  • Entry Point: The strategy buys when the price breaks above the upper channel (green line).
  • Exit Point: It sells when the price closes below the lower channel (red line).
  • This simple approach effectively captures trending markets.

Evaluating Performance

The performance report reveals:

  • An equity curve trending upward.
  • A profit of $192,000 over 58 trades.
  • An average profit of over $3,300 per trade.
  • A maximum intraday drawdown of about $83,000.
20Day Channel Performance
20Day Channel equity curve

We don't have a lot of trades for this strategy, which could be a problem. However, the concept looks good as we have a rising equity curve. Of course, the NASDAQ market has a long side bias so building long trading systems is really easy to do. 

Let's try a different timeframe to generate more trades.

Testing Different Timeframes

You don't have to limit yourself to daily charts. Let's switch to a 120-minute chart, where each bar represents two hours of trading.

Applying the same strategy:

  • Increased Trades: Shorter timeframes result in more trading opportunities.
  • Consistent Results: The strategy continues to capture significant trends.
  • Equity Curve: Shows consistent growth, even though individual trades might yield smaller profits.
20Day 120m Performance
20Day 120m equity curve

Looking at the equity curve, it's far from perfect, but we have an upwards rising equity curve that is clearly making money. Keep in mind we don't have any filters, stops or exits on this strategy. It's just the starting point of a breakout strategy. Furthermore, it's is non-optimized and it's really easy to build.

Enhancing the Strategy

What would I do to improve the strategy? Well, I've talked about that in other articles but in short, I would test different filters. Maybe a regime filter so the strategy is only taking  long trades in a strong bull market. I might try an ADX for filtering on volatility. I would also, of course, put in stops, and test profit targets.

The point of this article isn't to show you a complete system, but is to show you that just a few lines of easy language code can produce a breakout strategy that looks really good without profits, targets, without stop losses, or without adding any other filters. The skeleton of this strategy is solid—that's the true power of breakout strategies.

  • Adding Profit Targets: Set specific profit goals for your trades.
  • Implementing Regime Filters: Use filters to only take trades in favorable market conditions, such as a strong bull market.
  • Applying Volatility Filters: Incorporate indicators like ADX to filter based on market volatility.
  • Setting Stop Losses: Always recommended to manage risk effectively.

Common Rookie Mistakes to Avoid

While breakout strategies offer many advantages, it's important to steer clear of common pitfalls:

Mistake #1: Reinventing the Wheel

Many traders attempt to create exotic trading systems from scratch. If you're not consistently making money yet, stick to what works. Simplify your approach. Breakout systems are easy to understand, easy to code, and are proven models used by many successful traders.

Mistake #2: Overcomplicating Your Strategy

The strength of a breakout strategy lies in its simplicity and clarity. Simple strategies are often more adaptable and continue to work well into the future. Stick to straightforward rules and avoid overcomplicating your strategy. By doing so, you'll enhance adaptability and long-term effectiveness.

By avoiding these common mistakes, you'll be well on your way to trading success.

Key Takeaways

  • Breakout Strategies Are Momentum-Based: They capitalize on upward market movements by buying into strength.
  • Reduced Risk: Day trading with breakout strategies minimizes exposure to overnight market risks.
  • Adaptable and Scalable: These strategies can be tailored to different market conditions and applied across various markets and timeframes.
  • Proven Effectiveness: Decades of use have shown that breakout strategies consistently work.
  • Ideal for All Levels: Suitable for both beginners and seasoned traders looking for a robust trading approach.

What The Video Version of This Article

Final Thoughts

Today we've explored the powerful benefits of breakout trading strategies—from reducing risk to offering scalability across markets. Breakout systems work, and I highly recommend considering them before exploring more complex trading methods.

Here are some related articles to breakout trading

That's all for now.

]]>
https://easylanguagemastery.com/getting-started/the-powerful-benefits-of-breakout-trading-systems/feed/ 0
Riding the Market Waves: How to Surf Seasonal Trends to Trading Success https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/?utm_source=rss&utm_medium=rss&utm_campaign=market-seasonality-study-may-2019 https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/#comments Mon, 26 Aug 2024 10:00:00 +0000 http://easylanguagemastery.com/?p=19871

Remember that old Wall Street chestnut, "Sell in May and go away"? Well, grab your favorite beverage and settle in, because we're about to dive into this age-old wisdom and see if it really holds water.

Now, I don't know about you, but I've always been a bit skeptical of these catchy market phrases. They sound great at cocktail parties, but do they actually work? That's exactly what I set out to discover.

In this article, we're going to break down our Market Seasonality Study step by step.

Below is a graph of the market with a "buy" at the start of the strong period and a "sell" at the end of the strong period.

Testing the "Buy in November, Sell in May" Strategy

To evaluate the popular trading concept of buying the S&P in November and selling in May, I set up a test with the following parameters:

  • Market: S&P cash market
  • Time period: 1960 to present
  • Position sizing: Risk-adjusted, with $5,000 risked per trade based on market volatility
  • Transaction costs: Not included (no slippage or commissions accounted for)

The core logic of this strategy can be implemented in EasyLanguage as follows:

CurrentMonth = Month(Date);
If (CurrentMonth = BuyMonth) And (MP = 0) Then
Buy("Buy Month") iShares contracts next bar at market;
If (CurrentMonth = SellMonth) Then
Sell("Sell Month") iShares contracts next bar at market;

This code does the following:

  1. Determines the current month
  2. If it's the buy month (November) and we're not in the market, it enters a long position
  3. If it's the sell month (May), it exits the position

By using this simple logic, we can test whether this well-known market adage holds up over a long period of historical data.

Test Parameters and Assumptions

I decided to test the strategy on the S&P cash index, with data going back to 1960. The following assumptions were made for this test:

  • Starting account size: $100,000
  • Test period: January 1960 through May 2024
  • Position sizing: Full account size used when opening a new position
  • Equity management: P&L not accumulated to the starting equity
  • Transaction costs: No deductions for commissions and slippage
  • Risk management: No stops were used

With these parameters set, we can now input the key months for our seasonality strategy:

  • Buy month: November
  • Sell month: May

Using these inputs, we generated the following equity graph:

Buy November, Sell May

Buy November, Sell May

"Sell in May and Go Away" Strategy Results

The equity curve we generated visually represents the performance of our "Sell in May and Go Away" strategy over the 64-year test period. It allows us to see the long-term trend as well as any significant drawdowns or periods of exceptional growth. And I must say, it sure looks like these months have a long bias - those are some impressive results!

Let's break down the numbers:

  • Total Profit: $4,640,085
  • Max Intra-day Drawdown: $1,403,538
  • Net Profit vs Drawdown Ratio: 3.3

In simpler terms, for every dollar of drawdown, the strategy is making just over three dollars in profit. That's a respectable ratio by most trading standards.

Inverting the Strategy

But here's where it gets really interesting. What would happen if we flipped our strategy on its head? Instead of buying in November and selling in May, what if we did the opposite - buying in May and selling in November?

To find out, I inverted the BuyMonth and SellMonth inputs in our test. Here's the resulting equity curve:

Buy May, Sell November

Buy May, Sell November

Analyzing the Inverted Strategy Results

The inverted equity curve provides a fascinating contrast to our original strategy, allowing us to visually compare the performance of buying during the traditionally "weak" months versus the "strong" months.

Let's break down the performance of this inverted strategy:

  1. 1960-1970: The equity curve consistently declined.
  2. 1970-1978: It bottomed out and began to climb.
  3. 1978-1997: Steady growth, reaching an equity peak in 1997.
  4. 1997-2008: Entered a drawdown period, bottoming in 2008.
  5. 2008-2021: Recovered, reaching new equity highs in 2020 and 2021.

Key metrics for the inverted strategy:

  • Total Profit: $94,148
  • Max Intra-day Drawdown: $92,357
  • Net Profit vs Drawdown Ratio: 1.0

This 1:1 ratio indicates that you must endure a dollar of drawdown for every dollar of profit - a much less attractive risk-reward proposition compared to our original strategy.

Let's focus on the strong season period from November-May moving forward. Can we add a filter to improve the results?

Implementing a Simple Moving Average Filter

To refine our strategy and avoid potentially unfavorable entry and exit points, we're introducing a 30-period simple moving average (SMA) as a short-term trend filter. This addition aims to prevent us from:

  1. Buying immediately into a falling market
  2. Selling immediately into a rising market

Here's how it works:

  • For Selling: If May (our SellMonth) arrives and the market is rising (price above the 30-period SMA), we delay selling until the price closes below the SMA.
  • For Buying: If November (our BuyMonth) arrives, we only buy when the price closes above the SMA.

To implement this in EasyLanguage, we create two flags: BuyFlag and SellFlag. These indicate when the proper conditions for buying or selling are met based on our short-term trend filter.

if (MinorTrendLen > 0) Then 
BuyFlag = Close > Average(Close, MinorTrendLen)
Else
BuyFlag = true;

If (MinorTrendLen > 0) Then
SellFlag = Close < Average(Close, MinorTrendLen)
Else
SellFlag = true;

The MinorTrendLen variable is an input that determines the SMA's look-back period. An additional check allows us to enable or disable the SMA filter:

  • If MinorTrendLen > 0: The SMA filter is active
  • If MinorTrendLen = 0: Both flags are always true, effectively disabling the filter

This flexibility lets us easily compare performance with and without the filter.

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

Net Profit

$4,640,095

$5,961,005

Profit Factor

4.42

4.81

Total Trades

64

64

Avg.Trade Net Profit

$72,501

$93,140

Annual Rate of Return

9.54%

9.93%

Max Drawdown(Intraday)

$1,403,538

$1,856,564

NP vs Drawdown

3.3

3.2

We increased the net profit, profit factor, average profit per trade, and annual rate of return. There is a slight decline in the NP vs Drawdown ratio, but it's tiny. We can decently pull more profit by applying a simple moving average.

MACD Filter

A standard MACD filter is a well known indicator that may help with timing. I'm going to add a MACD calculation, using the default settings, and only open a new trade when the MACD line is above zero. Likewise, I'm only going to sell when the MACD line is below zero.  Within EasyLanguage we can create a MACD filter  by creating two Boolean flags called MACDBull and MACDBear which will indicate when the proper major market trend is in our favor.

If ( MACD_Filter ) Then
Begin
MyMACD = MACD( Close, FastLength, SlowLength );
MACDAvg = XAverage( MyMACD, MACDLength );
MACDDiff = MyMACD - MACDAvg;
If ( MyMACD crosses over 0 ) Then
Begin
MACDBull = True;
MACDBear = False;
End
Else If ( MyMACD crosses under 0 ) Then
Begin
MACDBull = False;
MACDBear = True;
End;
End
Else Begin
MACDBull = True;
MACDBear = True;
End;

Below are the results with the MACD filter:

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

MACD Filter

Net Profit

$4,640,095

$5,961,005

$4,685,543

Profit Factor

4.42

4.81

5.35

Total Trades

64

64

63

Avg.Trade Net Profit

$72,501

$93,140

$74,373

Annual Rate of Return

9.54%

9.93%

9.55%

Max Drawdown (Intraday)

$1,403,538

$1,856,564

$1,205,264

NP vs Drawdown

3.3

3.2

3.8

Utilizing the MACD filter and comparing it to our baseline system, we can see we don't make as much more as the simple moving average filter, however, we increased our risk adjusted return with a NP vs DD of 3.8. So, if drawdown is your concern and not just pure profit it looks the MACD filter is slightly better.

RSI Filter

For our final filter I will try the RSI indicator with its default loopback period of 14. Again, like the MACD calculation, I want price moving in our direction so I want the RSI calculation to be above zero when opening a position and below zero when closing a position.

If ( RSI_Filter ) Then
Begin
   RSIBull = RSI(Close, 14 ) > 50;
   RSIBear = RSI(Close, 14 ) < 50;
End
Else Begin
   RSIBull = true;
   RSIBear = true;
End;

Strong Seasonality Trade (November-May) With Filters

Baseline

SMA Filter

MACD Filter

RSI Filter

Net Profit

$4,640,095

$5,961,005

$4,685,543

$4,080,657

Profit Factor

4.42

4.81

5.35

4.24

Total Trades

64

64

63

64

Avg.Trade Net Profit

$72,501

$93,140

$74,373

$63,760

Annual Rate of Return

9.54%

9.93%

9.55%

9.34%

Max Drawdown (Intraday)

$1,403,538

$1,856,564

$1,205,264

$1,291,784

NP vs Drawdown

3.3

3.2

3.8

3.1

Filter Comparison Results

The RSI filter performed worse than both the MACD and SMA filters.

In the end, it appears that applying either an SMA filter or an MACD filter can improve the baseline results. Both filters are relatively simple to implement and were tested for this article using their default values. Of course, this simple study could be expanded much further.

Applying Filters to the Weak Seasonality Period

After performing the different filter tests and selecting the simple moving average filter as the most effective, I began to wonder how our three filters would perform if applied to the weak seasonality period. Below are the performance results.

Weak Seasonality Trade (May-November) With Filters

No Filter

SMA Filter

MACD Filter

RSI Filter

Net Profit

$94,148

$244,406

$221,672

$121,740

Profit Factor

1.42

1.67

1.79

1.52

Total Trades

64

64

63

64

Avg.Trade Net Profit

$1,471

$3,818

$3,518

$1,902

Annual Rate of Return

3.64%

5.03%

4.88%

4.00%

Max Drawdown (Intraday)

$92,357

$128,921

$106,121

$100,544

NP vs Drawdown

1.0

1.7

2.0

1.2

We can see that adding MACD Filter produces the best results in terms risk adjusted return (NP vs Drawdown). The SMA Filter products the best results in terms of net profit. Both provide a radical change when compared to the No Filter situation. 

Conclusion

It certainly appears there is a significant seasonal edge in the S&P market. The trading rules we used above for the S&P cash market could be applied to the SPY and DIA ETF markets. I've tested these ETFs, and they produce very similar results. The S&P futures market also yields comparable outcomes. Interestingly, this approach even seems to work well for some individual stocks.

Keep in mind that this market study did not utilize any market stops. This is not a complete trading system!

Practical Use: Market Regime Filter For Stock Index Markets

With some additional work, an automated trading system could be built from this study. Another application would be to use this study as a filter for other trading systems. I envision using these results as a regime filter for your existing trading systems that trade the stock index markets.

Strong Season Bull/Bear Filter

  • Bull Market = if price is above 30-day SMA
  • Bear Market = if price is at or below 30-day SMA

Weak Season Bull/Bear Filter

  • Bull Market = if MACD is above zero
  • Bear Market = if MACD is at or below zero

This seasonality filter could be applied to both automated trading systems and discretionary trading. While it may not be particularly helpful for intraday trading, it's worth testing in that context as well.

Being aware of these major market cycles can be invaluable in understanding current market conditions and potential future directions. This knowledge can enhance your overall market perspective and potentially improve your trading decisions.

I hope you found this study helpful and that it provides you with new insights for your trading strategies.

]]>
https://easylanguagemastery.com/market-studies/market-seasonality-study-may-2019/feed/ 2
Exploring Price-Time Filtering in Trading https://easylanguagemastery.com/indicators/exploring-price-time-filtering-in-trading/?utm_source=rss&utm_medium=rss&utm_campaign=exploring-price-time-filtering-in-trading https://easylanguagemastery.com/indicators/exploring-price-time-filtering-in-trading/#respond Mon, 15 Jul 2024 10:00:00 +0000 https://easylanguagemastery.com/?p=534623

The Price-Time Filter Indicator

It's essential to identify genuine market trends for consistent trading success. Many traders find distinguishing between random price fluctuations and real trading signals challenging, which can lead to missed opportunities or false entries. Today, we'll explore an intriguing technique called Price-Time Filtering, designed to filter out market noise and emphasize significant trends with greater clarity.

This article was inspired by Alfred François Tagher's insightful article, "Trend Identification By Price And Time Filtering," featured in the February 2024 issue of Stocks & Commodities magazine. In it, Tagher introduced the Price-Time Filtering technique. This method leverages the power of both price and time to identify trends, making it a robust tool for traders seeking to enhance their market analysis. When applied correctly, this method can provide a clearer picture of market movements and help traders make more informed decisions.

This article will delve into the price-time filtering technique and apply it to several future markets. By the end, we'll have a deeper understanding of how this technique works, its potential advantages, and how to incorporate it into your trading toolkit.

Practical Application of the Price-Time Filter

Imagine trying to listen to a piece of music in a noisy environment. In this scenario, you need some type of filter to remove the noise so you can hear the music more clearly. This is what your canceling headsets do.

In the trading world, price-time filtering isolates trends, allowing you to trade in the overall market direction. don't see the Price-Time filter as a signal generator to go long or short. Instead, it will help align trades with the prevailing market direction, reducing the risk of false signals and improving the consistency of trading results.

Well, that's the theory, anyway. I don't know if it will work, but that's what we're testing with this article.

Implementing the Price-Time Filter in EasyLanguage

Implementing the price-time filtering technique is straightforward with EasyLanguage for those using TradeStation or MultiCharts. Below, I provide code examples for the weekly timeframes, which I plan to focus on in this article. 

EasyLanguagee Code For Price-Time Filter:

{ Price-Time Filtering - Weekly }

Inputs: UpColor(Green), DnColor(Red);
Vars: WeekHi(0), WeekLo(0), WeekCl(0), PriorWeekHi(0), PriorWeekLo(0), Trend(0), WeekKnt(0);

{ Check for end of the week }
If (DayOfWeek(Date) < DayOfWeek(Date[1]) and DayOfWeek(Date[1]) <> 5) or (DayOfWeek(Date) = 5) then begin
If DayOfWeek(Date) = 5 then WeekCl = Close else WeekCl = Close[1];

If WeekCl > PriorWeekHi then Trend = +1;
If WeekCl < PriorWeekLo then Trend = -1;

PriorWeekHi = WeekHi;
PriorWeekLo = WeekLo;
WeekKnt = WeekKnt + 1;
end;

{ Reset weekly high and low }
If DayOfWeek(Date) < DayOfWeek(Date[1]) then begin
WeekHi = High;
WeekLo = Low;
end;

{ Update weekly high and low }
If High > WeekHi then WeekHi = High;
If Low < WeekLo then WeekLo = Low;

{ Plot the trend }
If WeekKnt > 1 then begin
If Trend = +1 then Plot1(High, "Week UP", UpColor);
If Trend = -1 then Plot1(Low, "Week DOWN", DnColor);
end;

Explanation

1. Inputs: These are user-defined parameters for the colors used in the plots.

2. Variables: These store the high, low, and close prices for the current and prior periods, as well as the trend direction and counters.

3. End of Period Check: The script checks if the current day is the week's or month's end and updates the trend accordingly.

4. High and Low Updates: The script continuously updates the highest and lowest prices observed throughout the period.

5. Plotting: The script plots the trend direction based on the evaluated conditions.

Below is an image of a PaintBar indicator using the Price-Time filter. Bearish trends are coloring the price bars red. Bullish trends are in green.

Price-Time Filter example

Price-Time Filter example

Testing the Price-Time Filter

I transformed the indicator into a simple trading strategy to evaluate the effectiveness of the Price-Time Filtering technique. This strategy will buy when the filter indicates an uptrend and sell short during a downtrend. By doing this, we can gauge how well the Price-Time Filter can identify and capitalize on trending markets.

Here's the plan:

  1. Strategy Setup:
    • We'll use the EasyLanguage code for the Price-Time Filtering indicator, which we've already discussed.
    • The strategy will enter a long position when the filter signals an uptrend and enter a short position when it signals a downtrend.
    • We'll be using the Weekly version of the Price-Time Filter.
  2. Testing Parameters:
    • We'll apply this strategy to several futures markets that represent a good basket of unique markets I trade, including:
      • Soybeans (S)
      • Euro Currency Futures (EC)
      • Crude Oil (CL)
      • S&P 500 (ES)
      • Gold (GC)
    • The testing will use daily bars to capture significant price movements over time.
    • We'll be using historical dates from 2000-2023. 
    • Slippage and commission will not be taken into account for this analysis.
  3. Performance Metrics:
    • We'll evaluate the strategies based on key performance metrics such as net profit, maximum drawdown, and net profit vs. maximum drawdown ratio.
    • Additionally, we'll analyze the average duration of trades to understand how long trends typically last.

By converting the Price-Time Filter into a simple strategy and testing it across different futures markets, I aim to provide you with actionable insights into its effectiveness. This practical approach will help you determine if this method can enhance your trading systems and improve your overall trading success. In the following sections, we'll dive into the results of these tests and draw meaningful conclusions to guide your trading decisions.

Price-Time Results

Now it's time to test this indicator on our markets. Below is a table with the results of apply the Price-Time strategy.

S

EC

CL

ES

GC

Net Profit

-31,687

$39,012

$157,480

$31,612

-$112,670

Profit Factor

0.89

1.12

1.36

1.36

1.09

0.79

Total Trades

216

216

200

222

254

Avg.Trade Net Profit

-$146

$180

$787

$142

-$443

Max Drawdown (Intra-Day)

$82,800

$49,056

$117,960

$74,412

$135,650

NP vs. DD

-0.3

0.7

1.3

0.4

-0.8

Some markets yield higher net profits than others which is expected. Soybeans and Gold do not perform well, whereas Crude Oil performs the best.

I couldn't help but notice that the Price-Time filter serves as a momentum or trend indicator. Thus, the markets with higher net profit are likely markets that have some trending characterisitic.

What if we were to invert the trading logic? We'll explore that in the next section.

Inverted Price-Time Results

In this case we're going to do the opposite of the original rules. That is, when we get a long signal, we're going to sell short. Why? We want to test the mean reversion characteristic of the market. We would expect to see results that are opposite of above. 

S

EC

CL

ES

GC

Net Profit

31,687

-$39,012

-$157,480

-$31,687

$112,670

Profit Factor

1.09

0.89

0.73

0.92

0.79

Total Trades

222

216

200

222

254

Avg.Trade Net Profit

$142

-$180

-$787

-$142

-$443

Max Drawdown (Intra-Day)

$74,412

$73,237

$266,450

$74,962

$88,090

NP vs. DD

0.4

-0.5

-0.6

-0.4

1.2

We can see that soybeans and gold do much better while the other market moves into negative territory. This tells me that Soybeans and Gold have mean reverting characteristics while the other markets have more trending characteristics. At least based on this indicator and this indicators hold times. We'll look at hold times in the final table. below.

Let's now create a table with the best results for each market.

Price-Time Best Results

In this table we're going to select the best performing side (Long, Short, or Both) and we'll select the best performing trading style (Trend Following or Mean Reversion)

S
Long MR

EC
Both TF

CL
Both TF

ES
Long MR

GC
Long MR

Net Profit

61,212

$39,012

$157,480

$87,950

$118,270

Profit Factor

1.61

1.12

1.36

1.54

1.71

Total Trades

108

216

200

111

127

Avg.Trade Net Profit

$566

$180

$787

$792

$931

Max Drawdown (Intra-Day)

$32,100

$49,056

$117,960

$40,462

$67,300

NP vs. DD

1.9

0.8

1.3

2.1

1.7

Avg. Bars in Trades

31

36

39

47

29

The weakest market is the Euro Currency Futures. The Price-Time filter does not hold some potential when using the mean reversion version of the indicator.  

The Crude Oil market does best in terms of net profit while talking both  long and short trades, with our filter acting as a trend-following indicator. See the image below for example trades. Click on the image for a larger version.

Price-Time Chart of Crude Oil With Trades

Price-Time Chart of Crude Oil With Trades

The remaining markets (Soybeans, S&P 500, Gold) all do well on the long side, with our filter acting as a mean reverting indicator.

What have we learned?

We have discovered which trading style (mean reversion or trend following) may work well for each market and which side of the market we should trade (long, short, or both).

This can be valuable information! We now have some critical information if we wish to start building trading systems on the daily timeframes for these markets.

Remember, depending on the market, the average holding time for these trades is between 29 days (GC) and 47 days (ES). So, the characteristics we're measuring in this study must unfold over several weeks.

How could you use this indicator?

As stated earlier, the Price-Time filter is not meant to generate trading signals. We used it to perform our market study this way, but it's better as a filter. 

For example, you might use this indicator on the ES market to activate your trading model and start looking for long trades. 

I did not explore the monthly signals in this study. However, the code can be modified to use the monthly closing price to produce an even longer-term filter, which presents a promising avenue for future studies. You will find that code in the original article, requiring a subscription to Technical Analysis For Stocks & Commodities magazine. I recommend the publication highly.

Lastly, if you trade intraday strategies, use this filter on a daily chart to filter which direction you should be trading on your 60-minute chart. This is another idea worth testing.

]]>
https://easylanguagemastery.com/indicators/exploring-price-time-filtering-in-trading/feed/ 0
Evaluating Gap Momentum in Futures Markets https://easylanguagemastery.com/getting-started/evaluating-gap-momentum-in-futures-markets/?utm_source=rss&utm_medium=rss&utm_campaign=evaluating-gap-momentum-in-futures-markets https://easylanguagemastery.com/getting-started/evaluating-gap-momentum-in-futures-markets/#respond Mon, 01 Jul 2024 10:00:00 +0000 https://easylanguagemastery.com/?p=534317

Have you ever wondered if the seemingly random gaps that occur when the market opens could be the key to a powerful trading strategy? Imagine turning these unpredictable moments into a reliable edge in your futures trading. Today, we're diving deep into the gap momentum strategy to uncover its true potential and see if it can revolutionize your trading game.

Gap momentum trading is a fascinating strategy that taps into the often-overlooked phenomenon of market gaps. This technique draws its inspiration from the pioneering work of J. Welles Wilder and Joseph Granville's innovative On-Balance-Volume (OBV) method. Wilder, known for developing several technical analysis tools, was keenly interested in market gaps and their implications. Granville's OBV method, which accumulates volume based on price movements, laid the groundwork for analyzing momentum in a novel way.

By examining the difference between today's open and yesterday's close, traders can accumulate a series of positive and negative gaps to derive a gap ratio. When smoothed with a moving average, this ratio becomes a powerful indicator of market momentum.

In this article, inspired by Perry J. Kaufman's work in "Gap Momentum," published in Technical Analysis of Stocks & Commodities, we will delve into the mechanics of the gap momentum strategy, explore its application in futures markets, and present our findings from extensive testing.

I aim to determine whether this technique can offer a reliable edge in futures trading and provide actionable insights for algorithmic traders looking to enhance their strategies.

Understanding Gap Momentum

Historical Context

To fully appreciate the gap momentum strategy, it's essential to understand its roots. This approach draws heavily from the work of two notable figures in technical analysis: J. Welles Wilder and Joseph Granville. Wilder, a renowned technical analyst, developed several widely used indicators, including the Relative Strength Index (RSI) and the Average True Range (ATR). His fascination with market gaps—those sudden jumps in price that occur when the market opens—led to insights about their potential impact on future price movements.

Joseph Granville, another pioneer in technical analysis, introduced the On-Balance Volume (OBV) method. OBV accumulates volume based on whether prices close higher or lower than the previous day. This cumulative volume can reveal trends only after a period of time from price data alone. Granville's work showed that volume precedes price, meaning significant volume changes often lead to price movements.

Concept Explanation

Building on these foundations, the gap momentum strategy uses opening gaps to gauge market momentum. Here's a step-by-step breakdown of how this works:

  1. Identify the Gap: The gap is simply the difference between today's opening price and yesterday's closing price. If today's open is higher than yesterday's close, it's a positive gap. If it's lower, it's a negative gap.
  2. Calculate the Gap Ratio:
    • Positive Gaps: Sum all positive gaps over a set period (e.g., 20 days).
    • Negative Gaps: Sum all negative gaps (as positive numbers) over the same period.
    • Gap Ratio: Divide the sum of positive gaps by the sum of negative gaps. This ratio reflects the balance of upward versus downward momentum.
  3. Create a Cumulative Series: Starting with zero, add the gap ratio to a cumulative total each day. This running total is the gap momentum indicator.
  4. Smooth the Indicator: Apply a moving average to the gap momentum indicator to smooth out the noise and provide a clearer signal. The length of this moving average can vary, but a common choice is 20 days.

Example Calculation:

Let's walk through a simple example with a 5-day period:

  • Day 1: Open = 102, Close = 100, Gap = 2 (positive)
  • Day 2: Open = 101, Close = 103, Gap = -2 (negative)
  • Day 3: Open = 104, Close = 101, Gap = 3 (positive)
  • Day 4: Open = 102, Close = 104, Gap = -2 (negative)
  • Day 5: Open = 105, Close = 103, Gap = 2 (positive)

Summing the gaps over 5 days:

  • Positive Gaps: 2 + 3 + 2 = 7
  • Negative Gaps: 2 + 2 = 4
  • Gap Ratio: 7 / 4 = 1.75

Each day, we add this ratio to the cumulative series. If we start with zero, the cumulative series over five days will be:

  • Day 1: 0 + 1.75 = 1.75
  • Day 2: 1.75 + 1.75 = 3.5
  • Day 3: 3.5 + 1.75 = 5.25
  • Day 4: 5.25 + 1.75 = 7
  • Day 5: 7 + 1.75 = 8.75

Trading Signals

Once we have our smoothed gap momentum indicator, we can use it to generate trading signals:

  • Buy Signal: When the smoothed gap momentum indicator turns upward, indicating increasing positive gaps.
  • Sell Signal: When the smoothed gap momentum indicator turns downward, indicating increasing negative gaps or decreasing positive gaps.

By following these signals, traders can capture the momentum market gaps indicate. 

Understanding the theory and calculation behind the gap momentum indicator is crucial. In the next section, we'll dive into how to implement this strategy in EasyLanguage and test it on various futures markets to see how it performs.

Implementing the Gap Momentum Strategy

Implementing the gap momentum strategy in EasyLanguage involves several steps, from setting up the inputs and variables to calculating the gap momentum indicator and generating trading signals. Here’s a detailed guide to help you understand and implement this strategy.

Step 1: Defining Inputs and Variables

First, we must define the inputs and variables used in our EasyLanguage script. These include the number of periods to evaluate gaps, the period for calculating the signal average, and the trading bias (long, short, or both).

// Inputs
Inputs:   
   iPeriod(40), // Number of periods to evaluate gaps
   iSignalPeriod(20), // Period for calculating the signal average
   iSignalTrigger(1), // Number of bars to look back on signal trigger
   iLSB(0); // Control trading bias: Long, Short, or Both
// Variables
Variables:   
   vSignal(0); // Calculated signal based on gap ratio

Step 2: Calculating Gap Momentum

We then calculate the gap momentum using a custom function. This function evaluates the gaps over the specified period and computes the gap ratio.

// Function to calculate Gap Momentum
Inputs: 
   iPeriod(NumericSimple), // Number of periods to evaluate gaps
   iSignalPeriod(NumericSimple); // Period for calculating the signal average
Variables: 
   vGap(0), // Difference between current open and previous close
   vUpGaps(0), // Sum of positive gaps
   vDnGaps(0), // Sum of negative gaps
   vGapRatio(0), // Ratio of up gaps to down gaps
   vIndex(0), // Loop index variable
   vSignal(0); // Calculated signal based on gap ratio
vUpGaps = 0;
vDnGaps = 0;
// Loop through the specified period to calculate gaps
for vIndex = 1 to iPeriod
begin
   vGap = open[vIndex] - close[vIndex + 1]; // Calculate the gap
   if (vGap > 0) then 
      vUpGaps = vUpGaps + vGap // Accumulate positive gaps
   else if (vGap < 0) then 
      vDnGaps = vDnGaps - vGap; // Accumulate negative gaps
end;
// Calculate gap ratio
if vDnGaps = 0 then 
   vGapRatio = 1 // Avoid division by zero
else 
   vGapRatio = 100 * vUpGaps / vDnGaps; // Calculate the ratio
// Calculate the signal as the average of the gap 
ratio
vSignal = Average(vGapRatio, iSignalPeriod);
// Return the signal
Gap_Momentum = vSignal;

Step 3: Implementing Trading Logic

After calculating the gap momentum, we implement the trading logic based on the signal generated. This involves buying or selling based on the direction of the gap momentum indicator.

Notice this is a stop-and-reverse strategy. Put another way, it's constantly switching between long and short.

vSignal = Gap_Momentum(iPeriod, iSignalPeriod);
// Trading logic based on the signal
if (marketposition <= 0 and vSignal > vSignal[iSignalTrigger]) then
begin
   Buy to cover all shares next bar on open; // Close short positions
   if (iLSB=1) or (iLSB=0) then
      Buy next bar on open; // Open long positions
end
else if (marketposition >= 0 and vSignal < vSignal[iSignalTrigger]) then
begin
   Sell all shares next bar on open; // Close long positions
   if (iLSB=-1) or (iLSB=0) then
      Sell short next bar on open; // Open short positions if allowed
end;

Step 4: Testing and Optimization

Finally, we test the strategy in various future markets to evaluate its performance. This involves running the script on historical data, which we'll do in the next section.

Testing the Strategy on Futures Markets

I will test this concept on the @ES, @GC, and @CL markets. I like to trade these markets and should provide a decent representation of the Gap Momentum concept.

I'm going to create three charts for each of our three markets to test with the following settings:

  • In-Sample History: 2006-2021
  • Out-of-Sample History: 2022-June 25, 2024
  • Timeframe: Daily Bars
  • Slippage and Commissions: $0
  • Maximum Bars: 200

I will then optimize the following Gap Momentum strategies across the following input ranges:

  • iPeriod: 5 to 60 in steps of 5
  • iSignalPeriod: 5 to 100 in steps of 5
  • iSignalTrigger: 1 to 10 in steps of 1
  • iLSB: -1 to 1 in steps of 1

After I optimize the in-sample historical data, I will apply the best settings to the out-of-sample data. This will give us a more realistic look at the performance.

Results of the Gap Momentum

@ES Market Results

It is not too surprising that the optimizer picked the long side as the best-performing. We see this constantly as the stock index markets have a historical long-side bias.  Below are the optimized results applied to the out-of-sample data segment. 

ES out-of-sample

ES out-of-sample

@GC Market Results

For the gold market, we're taking both long a short trades. However, the long side does appear stronger. This market appears to be the best performing with the Gap Momentum indicator. 

GC out-of-sample

GC out-of-sample


@CL Market Results

The crude oil market is also taking both long and short trades. The first thing I noticed was moving to the out-of-sample did very poorly. Virtually no net profit and huge drawdown.

GC out-of-sample

GC out-of-sample


@ES (Long)

@GC (Long/Short)

@CL (Long/Short)

Net Profit

$29,075

$53,620

$5,060

Profit Factor

1.25

1.56

1.02

Total Trades

87

60

173

Avg.Trade Net Profit

$234

$893

$29

Max Drawdown

$41,637

$25,530

$79,930

NP vs. DD

0.7

2.1

0.1

Summary Results of the Gap Momentum

Keep in mind these are not trading systems! This is a market study to test the potential value of using a Gap Momentum indicator in my trading. 

Overall, I'm not overly impressed with the results, but I will add it to my toolbox as it shows some promise.

Practical Application for Traders

How might you use Gap Momentum?

Understanding the theoretical foundation and implementation of the Gap Momentum strategy is just the beginning. To truly harness its potential, it is crucial to explore practical applications that can be seamlessly integrated into your trading routine. 

The Gap Momentum could be used as a filter for existing strategies. For example, when the gap ratio is climbing, this would be seen as a time to take long trades. If it's falling, this is a time to go short to halt trading. Below are more detailed examples.

Intraday Trading: You could use the Gap Momentum strategy to identify a bias in the market and focus on intraday price movements. If the Gap Momentum is rising, you look for intraday-long opportunities.

Swing Trading: For those who prefer holding positions for several days, the Gap Momentum strategy might help identify short-term trends and potential reversals, providing entry and exit signals based on accumulated gap data.

Risk Management: The strategy can be integrated into a broader framework. With gap momentum signals, traders can set more informed stop-loss levels and manage position sizes to reduce exposure during volatile market conditions.

Supplementing Technical Analysis: Gap Momentum can be used alongside other technical indicators to confirm signals. For example, traders might use it to validate signals from moving averages, RSI, or MACD, enhancing overall decision-making.

Volatility Trading: Traders can use the strategy to take advantage of periods of high volatility, where gaps are more prevalent. By focusing on markets and times when gaps are common, they can exploit these opportunities for potential profits.

Key Takeaways

In this article, we delved into the gap momentum trading. Here are the key takeaways:

  1. Understanding Gap Momentum:
    • Gap momentum trading leverages the differences between today's opening price and yesterday's closing price to gauge market momentum.
    • The strategy draws inspiration from J. Welles Wilder and Joseph Granville’s On-Balance Volume (OBV) method, incorporating their insights into a modern trading approach.
  2. Calculating Gap Momentum:
    • Positive and negative gaps are accumulated over a specified period to calculate a gap ratio.
    • This gap ratio, when smoothed with a moving average, forms the gap momentum indicator used for generating trading signals.
  3. Implementing the Strategy:
    • We provided a detailed EasyLanguage script to calculate the gap momentum indicator and generate buy/sell signals.
    • The strategy involves defining inputs and variables, calculating gaps, computing the gap ratio, smoothing the indicator, and implementing trading logic based on the signal.
  4. Testing and Results:
    • The strategy was tested on various futures markets, including the E-mini S&P 500 (@ES), Gold (@GC), and Crude Oil (@CL).
    • Optimization of input parameters was conducted to evaluate performance, and results were analyzed for both in-sample and out-of-sample data.
  5. Practical Applications:
    • The Gap Momentum strategy might act as a primary single for a trading system. Other stops, target and exits will need to be explored.
    • The Gap Momentum indicator may act as a filter for strategies locating potential bias (long/short) in a given market. This how I plan on using the Gap Momentum indicator in my own trading.

By integrating the Gap Momentum strategy into your trading routine, you can potentially enhance your ability to filter the over all market bias (long/short) allowing you to generate better trading signals.

I plan on adding Gap Momentum as part of my testing process. In particular I'm looking at using it as a Regime Filter.

As always, continuous testing is required.

]]>
https://easylanguagemastery.com/getting-started/evaluating-gap-momentum-in-futures-markets/feed/ 0
A Cool And Easy Way To Analyze Chart Patterns With TradeStation https://easylanguagemastery.com/market-studies/a-cool-and-easy-way-to-analyze-chart-patterns-with-tradestation/?utm_source=rss&utm_medium=rss&utm_campaign=a-cool-and-easy-way-to-analyze-chart-patterns-with-tradestation https://easylanguagemastery.com/market-studies/a-cool-and-easy-way-to-analyze-chart-patterns-with-tradestation/#respond Mon, 17 Jun 2024 10:00:15 +0000 http://easylanguagemastery.com/?p=20789

Have you every tested different combinations of closing or opening relationships to uncover the following days probability of either closing up or down.  I am sure you have tested selling after two down closes or just the opposite:  buying after two up closes.  Testing the relationship between two days is easy but when you go beyond just two then the programming can become very difficult.

The inefficient way:


if c > c[1] and c[1] > c[2] and c[2] > c[3] then
buy somewhere tomorrow

What if you wanted to test different combination of up/down closes then you would need to go into the code and make the changes like...


if c < c[1] and c[1] > c[2] and c[2] > c[3] then
buy somewhere tomorrow

you would then need to verify, run and keep track of results. This is really a pain. I have come up with an easy way to accomplish looking at many patterns and letting the computer keep track of the results.

What you need is a simple and dynamic way to change the patterns based on each individual run. We know we can use TradeStation’s optimizer to create multiple runs. Now all we need is a way for TradeStation, based on the run number, to change the pattern or pattern number.

The following code does this:

value1 = patternTests - 1;

if(value1 > 0) then
begin

if(mod(value1,2) = 1) then patternBitChanger[0] = 1;
value2 = value1 - patternBitChanger[0] * 1;

if(value2 >= 8) then begin
patternBitChanger[3] = 1;
value2 = value2 - 8;
end;

if(value2 >= 4) then begin
patternBitChanger[2] = 1;
value2 = value2 - 4;
end;
if(value2 = 2) then patternBitChanger[1] = 1;
end;

Do you remember binary based systems where 0 – off and 1 – on? If you don’t remember its OK. Here is a quick review for everyone.

0 0 0 0 pattern = 0
0 0 0 1 pattern = 1
0 0 1 0 pattern = 2
0 1 0 0 pattern = 4
1 0 0 0 pattern = 8

Each 1 or 0 is a placeholder and its placeholder is a bit than can either be on or off. The leftmost bit is 1’s place. The next bit is the 2’s place. The next bit is the 4’s place. And finally the rightmost bit is the 8’s place. So if we plug in 1 1 1 1 we get (8 + 4 + 2 + 1) = 15. If we start counting at 0 [ 0 0 0 0 ] then we can represent 16 distinct patterns with our four bits. Following?

So using this bit scheme and TradeStation’s optimizer we can run 16 different patterns sequentially. Now how do we get the bit pattern scheme to relate to the last four day’s close to close relationships. This is where the eloquence continues [if I have to say so myself]. EasyLanguage has a library of powerful string functions. One of those is the ability to concatenate or add a string to a string.

Let’s pretend we are the computer and we are optimizing thru 16 different runs. Let’s call the first run [0 run]. In our tests 1’s will be represented by “+” and 0’s by “-“. Using our 4 bit scheme how to we represent the number 0? Zero means no bits are on so 0 = [0 0 0 0]. If we translate our bits to a string where 1’s are “+” and 0’s are “-” then we get “- – – -“]. Right? If a “+” represents an up close and “-” represents a down close then the string “- – – -” would indicate four straight down closes.

Run 0 = 0 0 0 0 = ” – – – – ” – four straight closes down
Run 1 = 0 0 0 1 = ” – – – + ” – three straight closes down followed by 1 up close
Run 2 = 0 0 1 0 = ” – – + – ” – two straight closes down, one up close, one down close
Run 3 = 0 0 1 1 = ” – – + + ” – two straight closes down, two straight closes up



Run 15= 1 1 1 1 = ” + + + + ” – four straight closes up

Following this scheme we can easily check out 16 different 4 day patterns. Let’s see what pattern is the most prolific on the long side. What do you guess – maybe after 4 consecutive down closes?

Simply buying the next bar’s open and exiting two days later, let’s see which pattern is king. Here is the pattern and its profit/loss:

Pattern

Binary Pattern

P&L

Pattern String

0

0000

$12,187

– – – – 

1

0001

$14,150

– – – + 

2

0010

$7,687

– – +–

3

0011

$5,425

– – + + 

4

0100

$2,412

– + – –

5

0101

$6,887

- + - +

6

0110

$7,500

– + + –

7

0111

$9,762

– + + +

8

1000

$13,850

+ – – – 

9

1001

$10,225

+ – – +

10

1010

-$12.0

+ – + –

11

1011

$7,700

+ – + +

12

1 1 0 0

$11,025

+ + – –

13

1101

$4,975

+ + – +

14

1110

-$1,312

+ + + –

15

1111

-$1,000

+ + + + 

Well it seems they were mostly winners but you shouldn’t buy after ” + + + + “ or "+ + + -". Pattern ” – – – +” was the best followed by ” + – – – “.

Oh yeah this was tested in the ES over the past five years so we are probably witnessing a bullish bias. Let’s see if we sell using the same patterns.

Pattern

Binary Pattern

P&L

Pattern String

0

0000

-$12,187.5

– – – – 

1

0001

-$14,150

– – – + 

2

0010

$7,687

– – +–

3

0011

-$5,425

– – + + 

4

0100

-$2,412

– + – –

5

0101

$6,887

- + - +

6

0110

-$7,500

– + + –

7

0111

-$9,762

– + + +

8

1000

-$13,850

+ – – – 

9

1001

-$10,225

+ – – +

10

1010

$12

+ – + –

11

1011

-$7,700

+ – + +

12

1 1 0 0

-$11,025

+ + – –

13

1101

-$4,975

+ + – +

14

1110

$1,312

+ + + –

15

1111

$1,000

+ + + + 

Well the bullish bias is definitely evident. The best 4 day pattern to sell the next bar is to wait for 4 consecutive up closes or 3 consecutive up closes followed by 1 down close.

Is there anything to this pattern recognition? I think it can be used to filter trades and that’s about it. We tested a four day pattern for illustration purposes only but that might be too many. A two day pattern might work better. Please check this out and let me know.

Here is the program in its entirety:

input: patternTests(14),orbAmount(0.20),LorS(1),holdDays(0),atrAvgLen(10);

var: patternTest(""),patternString(""),tempString("");
var: iCnt(0),jCnt(0);
array: patternBitChanger[4](0);

{written by George Pruitt -- copyright 2006 by George Pruitt
This will test a 4 day pattern based on the open to close
relationship. A plus represents a close greater than its
open, whereas a minus represents a close less than its open.
The default pattern is set to pattern 14 +++- (1110 binary).
You can optimize the different patterns by optimizing the
patternTests input from 1 to 16 and the orbAmount from .01 to
whatever you like. Same goes for the hold days, but in this
case you optimize start at zero. The LorS input can be
optimized from 1 to 2 with 1 being buy and 2 being sellshort.}

patternString = "";
patternTest = "";

patternBitChanger[0] = 0;
patternBitChanger[1] = 0;
patternBitChanger[2] = 0;
patternBitChanger[3] = 0;

value1 = patternTests - 1;

if(value1 > 0) then
begin

if(mod(value1,2) = 1) then patternBitChanger[0] = 1;
value2 = value1 - patternBitChanger[0] * 1;

if(value2 >= 8) then begin
patternBitChanger[3] = 1;
value2 = value2 - 8;
end;

if(value2 >= 4) then begin
patternBitChanger[2] = 1;
value2 = value2 - 4;
end;
if(value2 = 2) then patternBitChanger[1] = 1;
end;

patternString = "";

for iCnt = 3 downto 0 begin
if(patternBitChanger[iCnt] = 1) then
begin
patternTest = patternTest + "+";
end
else
begin
patternTest = patternTest + "-";
end;
end;

for iCnt = 3 downto 0
begin
if(close[iCnt]> close[iCnt+1]) then
begin
patternString = patternString + "+";
end
else
begin
patternString = patternString + "-";

end;
end;

if(barNumber = 1) then print(elDateToString(date)," pattern ",patternTest," ",patternTests-1);
if(patternString = patternTest) then begin

// print(date," ",patternString," ",patternTest); //uncomment this and you can print out the pattern
// if(LorS = 2) then SellShort("PatternSell") next bar at open of tomorrow - avgTrueRange(atrAvgLen) * orbAmount stop;
// if(LorS = 1) then buy("PatternBuy") next bar at open of tomorrow + avgTrueRange(atrAvgLen) * orbAmount stop;

if(LorS = 2) then SellShort("PatternSell") next bar at open;
if(LorS = 1) then buy("PatternBuy") next bar at open;

end;

if(holdDays = 0 ) then setExitonClose;
if(holdDays > 0) then
begin
if(barsSinceEntry = holdDays and LorS = 2) then BuyToCover("xbarLExit") next bar at open;
if(barsSinceEntry = holdDays and LorS = 1) then Sell("xbarSExit") next bar at open;
end;

-- George Pruitt from GeorgePruitt.com.

Update by Jeff Swanson 

While the code is available here in the article, Join our weekly newsletter (see below) to get an example TradeStation WorkSpace and the source code as an ELD.

]]>
https://easylanguagemastery.com/market-studies/a-cool-and-easy-way-to-analyze-chart-patterns-with-tradestation/feed/ 0
Boost Your Trading Efficiency: Scaling In for Better Average Prices https://easylanguagemastery.com/getting-started/boost-your-trading-efficiency-scaling-in-for-better-average-prices/?utm_source=rss&utm_medium=rss&utm_campaign=boost-your-trading-efficiency-scaling-in-for-better-average-prices https://easylanguagemastery.com/getting-started/boost-your-trading-efficiency-scaling-in-for-better-average-prices/#comments Mon, 06 May 2024 10:28:13 +0000 https://easylanguagemastery.com/?p=534144

What is Scaling Into A Trade?

Scaling-in is a trading technique where a trader enters a position gradually, in smaller increments, rather than entering the full position size all at once. 

When scaling-in, a trader divides their intended total position size into smaller lots and enters these lots at different price points or time intervals. The opposite of scaling in is taking a full position all at once, also known as "going all-in."

Let's look at a detailed example to illustrate how scaling-in works:

Suppose an algorithmic trader has developed a trading system that generates a buy signal for Stock XYZ. The trader's usual position size for this stock is 1000 shares, but they decided to scale into the position to manage risk and capture a better average entry price.

The trader's scaling plan is as follows:

  1. Buy 200 shares at the market price when the buy signal is generated
  2. Buy an additional 200 shares if the price drops by 1% from the initial entry price
  3. Buy another 200 shares if the price drops by 2% from the initial entry price
  4. Buy the final 400 shares if the price drops by 3% from the initial entry price

Benefits of Scaling Into A Position

One of the biggest challenges in trading is entering a position at the right time and price. Even with a well-designed trading system, it's impossible to consistently predict the exact bottom for a buy or the precise top for a sell. This is especially true in volatile or choppy markets, where prices can whipsaw up and down, making it difficult to pinpoint the ideal entry.

Scaling in helps mitigate this timing risk by spreading the entry over multiple price points. Instead of going all-in at a single price, the trader can buy or sell in smaller increments as the market moves. This approach offers several benefits:

1. Cost Averaging: Scaling in can help in averaging down the entry price when the price moves against the position initially. Adding to the position at lower prices reduces the average cost of the total position, potentially leading to better outcomes when the market rebounds.

2. Reduced Risk: If the initial entry is poorly timed (e.g., the market moves against your initial position), the impact is reduced because only a portion of the full position is affected. You can then add to your position at a better price, thus improving the average cost of your position. By scaling in, algorithmic traders can reduce the risk of entering a trade at a single, potentially unfavorable price. This approach helps reduce drawdowns.

Based on the scaling plan from the previous section, let's see how this plan might play out in two different scenarios.

Scenario 1:

  • Stock XYZ is trading at $50 when the buy signal is generated
  • The trader buys 200 shares at $50
  • The price drops to $49.50 (1% drop), and the trader buys another 200 shares
  • The price then rises and never looks back, closing the day at $52

In this scenario, the trader's average entry price is $49.75 ((200 * $50 + 200 * $49.50) / 400). By scaling in, the trader bought 400 shares at a better average price than if they had gone all-in at $50.

Scenario 2:

  • Stock XYZ is trading at $50 when the buy signal is generated
  • The trader buys 200 shares at $50
  • The price drops to $49.50 (1% drop), and the trader buys another 200 shares
  • The price drops further to $49 (2% drop), and the trader buys an additional 200 shares
  • The price then drops to $48.50 (3% drop), and the trader buys the final 400 shares
  • The stock closes the day at $48

In this scenario, the trader's average entry price is $48.75 ((200 * $50 + 200 * $49.50 + 200 * $49 + 400 * $48.50) / 1000). Although the stock closed lower than the initial entry price, the trader accumulated the full 1000 shares at a better average price by scaling in.

Now, let's compare this to an all-in approach in the same scenario:

Scenario 2 (All-In):

  • Stock XYZ is trading at $50 when the buy signal is generated
  • The trader immediately buys 1000 shares at $50
  • The price drops to $49.50, then to $49, and finally to $48.50
  • The stock closes the day at $48

The trader's average entry price in the all-in approach is $50, as they bought all 1000 shares at the initial price.

The difference in the average entry price between the two approaches is $1.25 per share ($50 - $48.75). This may seem like a slight difference, but it can significantly impact the trader's overall profitability, especially when dealing with larger position sizes or multiple trades over time.

In this scenario, scaling-in allowed the trader to take advantage of the falling price and accumulate shares at a lower average cost. This means that if the price starts to move back up, the trader will reach their breakeven point sooner and potentially realize larger profits.

On the other hand, the all-in approach left the trader fully exposed to the price drop, resulting in a higher average entry price and a larger unrealized loss when the stock closed at $48.

It's important to note that the all-in approach could outperform scaling-in if the price moves in the trader's favor immediately after entry. However, scaling in provides a way to manage risk and optimize entries in scenarios where the price moves against the trader initially.

Drawbacks to Scaling Into A Position

While scaling-in offers several benefits, it's essential to understand the potential downsides of this approach. One of the main drawbacks is the risk of missing out on profits if the price moves in the trader's favor immediately after the initial entry.

For example, if a trader scales into an extended position and the price quickly rises, they may have yet to accumulate their full desired position size before the price moves beyond their planned entry points. This can reduce overall profitability compared to going all-in at the initial entry price.

Additionally, scaling in may result in higher transaction costs, as the trader places multiple orders instead of a larger order. This can be particularly significant for traders with smaller account sizes or those trading instruments with high transaction fees. 

Lastly, the psychological aspect of scaling-in should not be overlooked. Some traders may find it challenging to stick to their scaling plan, especially if the price moves against them and they are tempted to abandon the trade before reaching their full position size. Of course, as algorithmic traders, this is less of an issue because your trading plan is executed automatically. However, you may still be tempted to intervene.

Scaling-In Is Martingale Trading And Is Dangerous!

The comparison between scaling in and martingale trading is a common misconception, and it's important to clarify the differences between the two approaches.

Martingale trading is a strategy in which a trader doubles their position size after every losing trade, with the idea that a winning trade will eventually recover all previous losses and generate a profit. This approach is hazardous and can blow up an account, as the position sizes can quickly become unmanageable. A series of consecutive losses can result in substantial drawdowns or even account ruin.

In contrast, scaling-in is a risk management technique that involves gradually entering a position in smaller increments rather than doubling down on losing trades. When scaling in, traders typically have a predefined plan for the number of increments, the size of each increment, and the price levels at which they will add to their position. The goal is to achieve a better average entry price and manage risk by limiting the impact of a single entry point, not to recover losses from previous trades.

We're all familiar with the concept that you should risk at most 2% of your trading account on any single trade. How would that look with the scale-in technique?

When using a 2% risk rule combined with scaling in, traders must ensure that their total risk across all scaled-in entries does not exceed 2% of their account balance. This requires careful planning and position sizing to maintain a consistent level of risk throughout the trading process.

Let's consider an example to illustrate how the 2% risk rule can be applied when scaling into a position:

Suppose a trader has a $50,000 account and wants to scale into a long position in Stock XYZ. The stock is currently trading at $100 per share, and the trader has determined that the stop-loss level will be placed at $95, which is 5% below the current price.

Using the 2% risk rule, the trader can risk up to $1,000 (2% of $50,000) on this trade. To calculate the maximum total position size, the trader divides the risk amount by the difference between the entry price and the stop-loss level:

Max total position size = $1,000 / ($100 - $95) = $1,000 / $5 = 200 shares

Now, the trader decides to scale into the position using three equal increments. They will buy 67 shares (rounded up from 66.67) at $100, $99, and $98, resulting in a total position size of 201 shares.

1. First entry: 67 shares at $100

2. Second entry: 67 shares at $99

3. Third entry: 67 shares at $98

If the price reaches the stop-loss level of $95, the trader will lose approximately $1,005 (201 shares * $5 loss per share), which is close to their 2% risk limit.

However, if the price moves in the trader's favor and they exit the trade at $105, for example, their profit would be $1,005 (201 shares * $5 profit per share).

In this example, the trader has effectively scaled into the position while adhering to their 2% risk rule. By dividing the total risk across multiple entries, the trader has reduced the impact of a single entry point and potentially improved their average entry price.

It's important to note that traders should also consider the impact of commissions when calculating their position sizes and risk levels. 

Does It Work? An RSI2 Example

Let's test scale-in on a simple trading system. We are using the well-known 2-period RSI strategy on the @ES.D market. We'll be moving to the micro contract to scale into our position. Remember, the micro contracts are 1/10 the size of the mini. Thus, if we buy 1 contract of the @ES market, the equivalent is 10 micro contracts. This will allow us the ability to scale into our position.

The trading rules are:

  • Initial entry when RSI(2) < 25
  • Sell position when RSI(2) > 75
  • No Stop
  • No Regime Filter
  • $1.50 commission and $1.25 slippage taken out per side.
  • All orders are next bar at market

Scale-In Rules are:

  • Initial purchase 4 contracts upon trading entry rules
  • Second purchase 3 contracts when Close falls below .1% of initial purchase price
  • Third purchase 3 contracts when Close falls below 1.5% of initial purchase price

Below is an example of a couple of trades.

Scale-in Example

The total number of contracts for a full position will be 10. I initiated the purchase of 4 contracts because dividing 10 over three entries is not a viable option when working with contracts. Can't buy a fraction of a contract!

Let's look at the results of our two simulations. One performing an all-in approach vs our scale-in technqiue.

Session

All-In

Scale-In

Net Profit

$168,535

$125,627

Profit Factor

1.67

1.72

Trades

339

646

Average Average Trade

$497.15

$194.47

Max Drawdown

$45,905

$39,169

NP vs DD

3.6

3.2

I would have to say the results are underwhelming. It's true that the Max Drawdown and Net Profit fell. That was expected, but the risk-adjusted return (NP vs DD) also fell. I would like to see this value increase, not fall.

In essence, we're generating less profit with only a marginal improvement in the drawdown. This serves as a valuable lesson in testing ideas. What may seem promising in theory, may not always yield the expected results in practice. This learning experience underscores the dynamic and unpredictable nature of trading strategies. 

Below is an example of the all-in (left side) take a trade. The scale-in (right side) is taking the same trade with three entries.

All In Example Trade
Scale-In Example Trade

I will test the same two strategies with a 200-bar regime filter added. I'll only take trades when the price is above this simple moving average.

Session

All-In

All-In Regime

Scale-In

Scale-In Regime

Net Profit

$168,535

$119,533

$125,627

$98,547

Profit Factor

1.67

1.83

1.72

2.05

Trades

339

253

646

466

Average Average Trade

$497.15

$472.46

$194.47

$211.47

Max Drawdown

$45,905

$25,042

$39,169

$19,577

NP vs DD

3.6

4.7

3.2

5.0

 By focusing our trades during a bull market, the scale-in version does what is intended. That is, we see an improvement in the risk-adjusted return. We go from a 4.7 to a 5.0 in the net profit vs. drawdown metric. It's not too impressive, but it's a positive change.

Conclusion: The Importance of Testing Scaling In Strategies

Throughout this article, we have explored scaling into positions as a technique for algorithmic traders using TradeStation and EasyLanguage. We have discussed the potential benefits, such as managing risk and optimizing entry prices. We have also provided examples of implementing scaling-in strategies using EasyLanguage code and shared tips for customizing your approach.

However, this exploration's most critical takeaway is the importance of testing your scaling-in strategies before deploying them in live trading. Using the RSI(2) strategy on the @ES.D market, the example we provided demonstrates that what may seem like a promising idea in theory may not always yield the expected results in practice.
In our initial test, we found that scaling into positions led to lower net profit and only a marginal improvement in drawdown, resulting in a decreased risk-adjusted return. This outcome highlights that not all scaling-in strategies will be effective in every market condition or with every trading system.

However, adding a simple 200-bar regime filter to focus our trades during a bull market showed a slight improvement in the risk-adjusted return. This finding underscores the importance of testing and refining your scaling-in strategy to suit your specific trading system and market conditions.

As algorithmic traders, it is crucial to approach scaling-in with a scientific mindset. Thorough backtesting and forward-testing of your strategies are essential to ensure they align with your trading objectives and risk management rules. It is also necessary to regularly review and optimize your scaling-in approach based on changes in your trading system's performance and market conditions.

Remember, the goal of scaling in is to improve your trading performance, not to add unnecessary complexity or risk to your system. By diligently testing and refining your strategies, you can determine whether scaling in is viable for your specific trading style and market conditions.

In conclusion, scaling into positions is a powerful tool for algorithmic traders using TradeStation and EasyLanguage. However, its effectiveness relies heavily on thorough testing, customization, and continuous optimization. By embracing the importance of testing and adapting your strategies to suit your unique trading environment, you can harness the potential benefits of scaling in and working towards achieving consistent, risk-adjusted returns.

The code I used for this study is available for download. See below.

]]>
https://easylanguagemastery.com/getting-started/boost-your-trading-efficiency-scaling-in-for-better-average-prices/feed/ 1
Unveiling the Best Performing Markets For A Momentum Trading Concept https://easylanguagemastery.com/building-strategies/unveiling-the-best-performing-markets-for-a-momentum-trading-concept/?utm_source=rss&utm_medium=rss&utm_campaign=unveiling-the-best-performing-markets-for-a-momentum-trading-concept https://easylanguagemastery.com/building-strategies/unveiling-the-best-performing-markets-for-a-momentum-trading-concept/#comments Mon, 22 Apr 2024 10:00:00 +0000 https://easylanguagemastery.com/?p=531164

In this article, I will look at a recent article by Kevin Davey. Kevin when back to the first issue of Technical Analysis Of Stocks & Commodities (TASAC) magazine to test a simple momentum-based trading idea. The EasyLanguage code for the strategy is provided. Let's get started.

What Is A Momentum Trading System?

Momentum trading systems are based on the idea that markets tend to continue moving in the same direction for some time. These systems aim to capitalize on this momentum by identifying trends and entering trades in the order of the movement.

One way to do this is using a momentum indicator, such as the Moving Average Convergence Divergence (MACD) or the Relative Strength Index (RSI). These indicators measure the trend's strength by comparing the current price to past prices. When the indicator is above a certain threshold, it may signal that the trend is strong, and the trader should enter a trade in the direction of the movement.

However, it's important to note that momentum can change quickly, and traders must be prepared for a trend reversal. This is where the concept of retracement comes in. By waiting for a retracement, or pullback, against the trend before entering a trade, traders can reduce the risk of being caught in a trend reversal or enter at a better price if the trend continues.

The Momentum Trading System

The TASAC magazine has been around for over 40 years! That's fertile ground for trading ideas. I've subscribed to TASAC for many years, and you can find interesting ideas to test. 

Kevin discovered a simple concept in an article titled "Handling Market Reactions" by John Rosenstock. Rosenstock's basic idea is to enter trades after a retracement against the trend. In the article, he writes: "All markets exhibiting prolonged price trends invariably have reactions against the trend."

The article posits that momentum reversal is an excellent way to jump back on the trend after a pullback. Momentum will be defined as today's closing price minus the closing price X days ago.

Momentum = Close - Close[x]

Kevin's interpretation used two momentum calculations. First, a longer-term momentum (LTM) will determine the market trend.

  • LTM > 0 is a bull market (long trades only)
  • LTM <= 0 is a bear market (short trades only)

Second, a shorter-term momentum (STM) calculation will determine a pullback in the overall market trend, which will be our entry point.

  • STM crosses above zero = buy
  • TM crosses below zero = sell short

The code in TradeStation EasyLanguage for the strategy looks like this:

momentum1=close-close[mlookback];
if momentum1 crosses above 0 and close>close[2*mlookback] then buy next bar at market;
if momentum1 crosses below 0 and close<close[2*mlookback] then sellshort next bar at market;


Next, Kevin added exits to the strategy, defined as after a few bars go against the trade. For long trades that means exiting after a recent lowest close is hit, and for short trades, that means exiting after a recent high. Below is the EasyLanguage code.

if marketposition=1 and close=lowest(close,rlookback) then
   sell next bar at market;
if marketposition=-1 and close=highest(close,rlookback) then
   buytocover next bar at market;

Below is an example of the recent price action (April-December of 2022) of the E-mini S&P with the momentum pullback strategy applied.

What we have here is not a trading system. This strategy code is just a simple price pattern-based entry and exit. This is a Key Idea and the start of a potential trading system. We will test this Key Idea on different markets and timeframes to see how it performs. I want to know what market or timeframes this Key idea is viable on. Doing so will give me a starting point for building a final trading system.

Testing Across Different Markets & Timeframes

I will use Tradesq to test this momentum code across all available futures markets and time frames. Tradesq is an online tool that will allow you to test your code and many popular futures markets across eight intraday timeframes. You can read more about Tradesq in the article, "How I Trade Like A Hedge Fund."

Futures markets tested include AD, BD, BO, BP, C, CC, CD, CL, CT, DX, EMD, ES, EU, FV, GC, GF, HE, HG, HO, JPY, KC, KW, LB, LE, MW, NG, NQ, OJ, PA, PL, RB, RR, RTY, S, SB, SF, SI, SM, TY, US, W, XG, YM.

The timeframes tested include the following:

  • Daily
  • 1,440-minute
  • 600-minute
  • 360-minute
  • 240-minute
  • 180-minute
  • 120-minute
  • 60-minute

I had Tradesq vary the rlookback between 2-20 in steps of one and mlookback between 25-100 in steps of 5. 

I performed two tests with Tradesq. The first was to look at the daily results and then look at the intraday results. 

Interpreting The Results

When Tradesq has completed all backtests, it generates a results table. This table lists the markets and the number of edges. 

What is an "edge?" An edge is a successful run that's passed filter requirements. Remember, we tested different lookback periods. 

When a particular run passes the filter, this is called an "edge." The higher edges mean more backtests in that specific category passed the filter. So, many edges show that more backtest produced passing results. For example, the different input values (our lookback period) had a passing performance. 

When a particular run passes the filter, this is called an "edge." The higher edges mean more backtests in that specific category passed the filter. So, many edges show that more backtest produced passing results.

The filter applied to the backtest required that a backtest must...

  • Minimum number of trades 50
  • Minimum PnL: $0
  • Minimum R2: .50
  • Minimum NP vs. DD: 1.0

Remember, this is a market study, not a complete trading system. It's a market study. We're not looking for great numbers; thus, the filter is not overly restrictive. 

Best Performing Markets on Daily Timeframe

I took the results from Tradesq and loaded them into a spreadsheet to find the best-performing markets. 

click table for larger view

The top-performing markets on the daily timeframe are

  1. Spring Wheat (MW)
  2. Hard Red Winter Wheat (KW)
  3. Lean Hogs (LH)
  4. E-mini Russel 2000 (RTY)
  5. VIX (VX)

I'm unfamiliar with the first two markets (MW, KW), but I traded LH, so this may interest me. I don't trade VX either, but  RTY I have traded.

Out of the top five, only the RTY version would be available as a micro contract. Thus, building a daily momentum strategy on RTY is an excellent place to start for a lot of traders, and looking into a momentum strategy on LH seems promising if you have a large enough account.

Best Performing Markets On Intraday Timeframes

I took the results from Tradesq and loaded them into a spreadsheet to find the best-performing markets. 

The top-performing markets on the daily timeframe are

  1.  Bitcoin (BTC)
  2. Etherium (ETH)
  3. Lean Hogs (LH)
  4. Soybean Oil (BO)
  5. Soybean Meal (SM)

We see the crypto markets rising to the top. I'm not too keen on trading these on a daily bar as those markets don't have a lot of history thus, they are generating too few trades.

We also have Lean Hogs making an appearance again. Because lean hogs appear on both the intraday and daily results, this may be an excellent market to trade this strategy. I'm not overly familiar with the other markets, BO and SM.

What's Next?

We covered just the first step in creating a trading system. We used tradesq to help us locate potential markets to look into. Next is to test the momentum key idea using my development process. My process is called the Profit Lab Method and consists of 10 steps. I teach this method as part of System Development Master Class

  1. Test various filters
  2. Test exits
  3. Validate the strategy
  4. Attempt to incorporate into a portfolio

I would start with Lean Hogs on a daily bar and then explore Lean Hogs on a 240-minute bar. 

If you want to work exclusively with micro contracts, look at the RTY & ES markets. Keep in mind just because we don't see other index markets like NQ or YM rising to the top, that we can't make a strategy for those markets. The Tradesq results are just great places to start.

What Else Can You Test?

Remember, we're testing both long and short trades. You could separate these. Build a version of this that only goes long. Then build another version that only goes short. This will allow you to have a unique lookback period for each. You could then use Tradesq to test all markets and time frames while only taking long trades. Then short trades only. Kevin Davey prefers not to do this, but it might be worth looking into.

Conclusion

In conclusion, Kevin Davey tested a momentum-based trading system using John Rosenstock's concept of entering trades after a retracement against the trend. The system used two momentum calculations to determine the overall market trend and identify pullbacks for entry points. The trading idea was tested across various futures markets and time frames using the Tradesq tool, and the results showed several promising markets. The next step would be to test various filters, exits, and stops to create a final trading system.

]]>
https://easylanguagemastery.com/building-strategies/unveiling-the-best-performing-markets-for-a-momentum-trading-concept/feed/ 2