The system consists of seven components:
- trend,
- momentum,
- directional movement,
- retracements,
- entries,
- stops,
- exits.
The first step in applying the Momentum-Retracement System is to determine the trend. We use a moving-average channel and the MACD Indicator to accomplish this task.
The moving-average channel includes exponential moving averages of 15 highs, 15 lows, and 5 closes. The trend is up when the 5-bar exponential average of the closes is above 15-bar exponential average of the highs, or when the 5-bar exponential moving average of the closes is above the 15-bar exponential moving average of the highs more recently than it was below the 15-bar exponential moving average of the lows.
Conversely, the trend is down when 5-bar exponential average of the closes is below the 15-bar exponential average of the lows or when the 5-bar exponential average of the closes was below 15-bar exponential average of the lows more recently than it was above 15-bar exponential average of the highs.
The MACD Indicator must confirm the trend identified by the moving-average channel. We use a 3–10–15 MACD. This means that the MACD line represents the difference between a 3-bar and a 10-bar exponential moving average, and that the signal line of the indicator is a 15-bar exponential moving average of the MACD line. When the signal line is above zero, the trend is up, and when the signal line is below zero, the trend is down.
The second step is to evaluate the market’s momentum. In this system, we use the Relative Strength Index (RSI). RSI compares the relative strength of price gains on bars that close above the previous bar’s close to price losses on bars that close below the previous bar’s close. A
5-bar RSI rising to 70 or higher signifies strong bullish momentum, and the RSI falling to 30 or lower indicates strong bearish momentum.
The third step is to measure the market’s directional movement. In this system, we use the Directional Movement Index (DMI). DMI consists of two lines — the DMIPlus line and the DMIMinus line. These two lines represent the amount of consistent bullish “trendiness” and consistent bearish “trendiness” respectively. We construct an indicator called the DMI Spread by subtracting the DMIMinus line from the DMIPlus line. A DMI spread of +15 or higher indicates a persistent uptrend, and a DMI spread of -15 or lower indicates a persistent downtrend.
The fourth step is to identify a retracement. A retracement refers to a countertrend decline in an uptrend or a countertrend rally in a downtrend. In this system, we specify three conditions that must be met for a qualifying retracement. In an uptrend, the three conditions are: 1) Prices decline into the moving-average channel (in other words, the low of a price bar crosses below the exponential moving average of 15 highs), 2) MACD crosses below the signal line, and 3) RSI declines from above 70 to below 50 or declines by at least 30 RSI points.
In a downtrend, the three conditions are: 1) Prices rally into the moving-average channel (i.e., the high of a price bar crosses above the exponential moving average of 15 lows), 2) MACD crosses above the signal line, and 3) RSI rises from below 30 to above 50 or rises by at least 30 RSI points.
These three conditions for retracements do not have to occur on the same bar. The requirement is that all three conditions occur within 10 bars of the highest high (in an uptrend) or within 10 bars of the lowest low (in a downtrend).
The fifth step is to determine the entry price. After a qualified retracement in an uptrend, we enter a long position when prices rally one third of the way back up between the low of the retracement and the high of the uptrend. For example, if the high of the uptrend is 124, and the low of the retracement is 112, we will set our buy stop at 116 (one third of the way back up).
After a qualified retracement in a downtrend, we enter a short position when prices fall one third of the way back down between the high of the retracement and the low of the downtrend. For example, if the low of the downtrend is 112, and the high of the retracement is 124, we will set our sell stop at 120 (one third of the way back down).
The setup for a buy entry is canceled if the exponential moving average of 5 closes crosses below the exponential moving average of 15 lows or if the signal line of the MACD crosses below zero. The setup to sell short is canceled if exponential moving average of 5 closes crosses above the exponential moving average of 15 highs or if the signal line of the MACD crosses above zero.
The sixth step is to determine our initial protective stop, our breakeven stop, and our trailing stop. For a long position, the initial protective stop is set one 10-bar average true range below our entry price; for a short position, the initial stop is set a 10-bar average true range above our entry price.
We move our stop to breakeven after a closing price that gives us an open profit equal to or greater than the initial risk on the trade. For example, if we bought a stock at $80 and set our initial stop at $77, we would raise our stop to $80 (breakeven) after a close of $83 or higher.
We’ll also place a profit-protect trailing stop. For a long position, we watch two trailing stops and place our profit-protect order at the higher of the two stops. The first stop is swing support to the power of two, which is defined as a price low that has at least two higher lows immediately before it and at least two higher lows immediately after it. The second stop is the exponential moving averages of 15 lows. Remember that we will place our stop at the higher of the two possibilities.
For a short position, we also watch two trailing stops and place our profit-protect order at the lower of the two stops. The first stop is swing resistance to the power of two, which can be defined as a price high that has at least two lower highs immediately before it and after it. The second stop is the exponential moving averages of 15 highs. We will place our stop at the lower of the two alternatives.
The seventh step is the exit. We exit from a long position on the next open when both the signal line of the MACD and the DMI spread fall below zero; we exit from a short position on the next open when both the MACD signal line and the DMI spread rally above zero.
Defining your Trading Rules
In this system, we defined both long entries and short entries as well as exit orders. We also did substantial setup work to calculate the moving average channel, momentum, and DMI. The setup, entries and exits are described next:
Setup
Calculate the 15-bar exponential moving averages of the highs and the lows and the 5-bar exponential moving average of the closing prices.
Calculate a 15-bar exponential average of the MACD (based on 3 and 10 bars).
Calculate the difference between the exponential average of the MACD calculated in b) and the underlying MACD.
Calculate the DMI spread by subtracting the DMI Minus from the DMI Plus, based on a length of 15 bars.
Long Entries
Determine the trend by comparing the exponential moving averages. The trend is up when: the 5-bar exponential average of the closes is above 15-bar exponential average of the highs, or when the 5-bar exponential moving average of the closes is above the 15-bar exponential moving average of the highs more recently than it was below the 15-bar exponential moving average of the lows.
Confirm the trend using the MACD. When the signal line is above zero, the trend is up.
Evaluate the momentum of the market using the RSI Indicator. A 5-bar RSI rising to 70 or higher signifies strong bullish momentum.
Determine the persistence of the trend using the DMI Indicator. We construct an indicator called the DMI Spread by subtracting the DMIMinus line from the DMIPlus line. A DMI spread of +15 or higher indicates a persistent uptrend.
Check for a retracement. In an uptrend, the three conditions are:
- Prices decline into the moving-average channel (in other words, the low of a price bar crosses below the exponential moving average of 15 highs),
- MACD crosses below the signal line, and
- RSI declines from above 70 to below 50 or declines by at least 30 RSI points.
These three conditions for retracements do not have to occur on the same bar. The requirement is that all three conditions occur within 10 bars of the highest high.
Short Entries
Determine the trend by comparing the exponential moving averages. The trend is down when: the 5-bar exponential average of the closes is below the 15-bar exponential average of the lows or when the 5-bar exponential average of the closes was below 15-bar exponential average of the lows more recently than it was above 15-bar exponential average of the highs.
Confirm the trend using the MACD. When the signal line is below zero, the trend is down.
Evaluate the momentum of the market using the RSI Indicator. A 5-bar RSI falling to 30 or lower indicates strong bearish momentum.
Determine the persistence of the trend using the DMI Indicator. We construct an indicator called the DMI Spread by subtracting the DMIMinus line from the DMIPlus line. A DMI spread of -15 or lower indicates a persistent downtrend.
Check for a retracement. In a downtrend, the three conditions are: 1) Prices rally into the moving-average channel (i.e., the high of a price bar crosses above the exponential moving average of 15 lows), 2) MACD crosses above the signal line, and 3) RSI rises from below 30 to above 50 or rises by at least 30 RSI points.
These three conditions for retracements do not have to occur on the same bar. The requirement is that all three conditions occur within 10 bars of thelowest low.
Exit Orders
Place protective stops. For a long position, we’ll set the initial protective stop at our entry price minus the 10-bar average true range; for a short position, we’ll set the initial stop at our entry price plus a 10-bar average true range.
We’ll also place a profit-protect trailing stop:
For a long position, we’ll watch two trailing stops and place our profit-protect order at the higher of the two stops. The first stop is swing support to the power of two, which is defined as a price low that has at least two higher lows immediately before it and at least two higher lows immediately after it. The second stop is one point below the exponential moving averages of 15 lows. We will place our stop at the higher of the two possibilities.
For a short position, the first stop is swing resistance to the power of two, which can be defined as a price high that has at least two lower highs immediately before it and after it. The second stop is one point above the exponential moving averages of 15 highs. We will place our stop at the lower of the two alternatives.
We exit from a long position on the next open when both the signal line of the MACD and the DMI spread fall below zero; we exit from a short position on the next open when both the MACD signal line and the DMI spread rally above zero.
Designing & Formatting
This section presents the EasyLanguage instructions and formatting for the system, with the EasyLanguage instructions broken down and explained line by line.
Inputs
Following is the list of all the inputs we used in this system:

In addition to these inputs, we define the following variables:

Setup
We begin by calculating the exponential averages. We use the function XAverage to calculate the three averages we will be using.

Then, we calculate the 15-bar expoential average of the MACD line and store the resulting value in the variable MACDSigLine (we’ll refer to this as the MACD signal line). We also subtract this average from the MACD line itself and store this value in MACDDiff (we’ll refer to this differential as the MACD differential. It represents the nearness of the MACD line to its smoothed average). Finally, we calculate the DMI spread and store this in the variable DMISpread.

Once we have the values we need, we can begin our comparisons. As described, we want to check for trend, momentum, directional movement and retracement. First, we look for a trend. We check to make sure that the 5-bar average of the closing prices is greater than the 15-bar average of the high prices and that the MACD signal line is greater than zero. We store the resulting true or false value in the variable TrendUp.
Then, we check the RSI to evaluate momentum. We use the RSI function to check whether or not the RSI (using the closing prices and 5 bars) is greater than or equal to 70, and then make sure the DMI spread is greater than 15. We store the resulting value, true or false, in the variable Momentum.

Long Entries
Once we have performed the comparisons, we check their values. If the trend is up and there is strong bullish movement (RSI >= 70), then we do three things: First, if Fase1 is False, then we set our variables HighestHigh and HighestRSI to zero. This will make sure we capture the current bar’s high and RSI values in these variables. Second, we set the variable Fase1 to True and the variable Fase2 to False. And three, we compare the high of the current bar to the value in HighestHigh. If the high is greater, we store it in HighestHigh. Likewise, we compare the value of the RSI to the value stored in HighestRSI and store the greater value in HighestRSI.
We use the variables Fase1 and Fase2 essentially to keep track of what we consider two distinct phases. The first phase is the up trend and the second phase is the retracement. As soon as we begin the second phase, we consider the first phase over and set Fase1 to False and set Fase2 to True, and vice versa.

Then, we check for a retracement. Four conditions must be true. First, Fase1 must be true, which means the trend is up and there is strong bullish movement, the 5-bar average of closing prices must be less then the 15-bar average of the high prices, the MACD differential must be less than zero, and one of the following must be true: the RSI is at or under 50 or the RSI is less than the HighestRSI minus 30. If they are, then the variable Retracement is set to True.

If there is a retracement then we do three things. First, if Fase2 is False then we set the LowestLow variable to 999999 (this ensures that we will capture the low of the current bar in the variable LowestLow in the next set of instructions). Second, we set the variable Fase2 to True and set the variable Fase1 to False. Third, we set the variable BuySwitch to False.

If Fase2 is True, meaning that there was first an up trend and bullish market momentum and a subsequent retracement, then we perform two actions: first, we check to make sure that the current low is less than the LowestLow. If it is, then we’ll store it in the variable LowestLow. And second, we set the variable BuySwitch to True.

Finally, if BuySwitch is True, which means there was a retracement, and we are currently not in a long position, then we place a buy stop order at the value stored in the variable LowestLow plus a third of the difference between the HighestHigh and LowestLow. This ensures that prices have to rally a third of the way back up between the low of the retracement and the high of the uptrend.

Once we are in a long position, or if 5-bar average of the closing prices is less than the 15-bar average of the low prices or the MACD signal line is less than zero, we will re-set our variables, BuySwitch, Fase1 and Fase2 to False.

The next set of instructions places exit orders. First, we check to see if we are in a long position. If we are not, then we place the exit order at the low of the current bar minus the 10-bar average of the true range. If we are, we place the exit order at the entry price minus the 10-bar average of the true range.
Consider this set of instructions. When we are not in a long position, we place an order to exit a long position. This statement enables us to place an exit for the bar of entry. As soon as we are in a long position, this exit order takes effect.

We also wanted to place a profit-protecting trailing stop. We consider two prices, the low of the swing resistance and the exponential moving averages of the low prices. First we determine when a swing low has occurred and we are in a long position, we use the functions SwingLow and MarketPosition, respectively, to do this. When these two conditions are true, we store the low of the swing bar in the variable ExitPrc. We then use the MinList function to determine which value is lower, the 15-bar exponential moving average of the low prices (LowXMA) or the value stored in ExitPrc. Whichever is lower is stored in the variable ExitPrc. Then, we place a stop order to exit our long position at the price stored in the variable ExitPrc.

Testing & Improving
For simplicity, tests were carried out on various underlyings with the Daily timeframe, nothing prevents you from trying other timeframes and other underlyings, the strategy is complete and at your disposal
Let’s see the results..












Suggestions for Improvement
This system was tested without any optimization. The results could almost certainly be improved by proper optimization. Inputs that could be optimized include the values for the EMA of highs, EMA of lows, EMA of closes, MACD, RSI, and DMI spread. We could also optimize the levels of the RSI and DMI spread (currently 70–30 for RSI and +15, -15 for the DMI spread). The percent of the countertrend move that must be “taken back” by a resumption of the major trend is another candidate for optimization (the percent is currently fixed at 33%).
The system’s stops could also be optimized. The initial protective stop (currently set at one average true range from our entry point) could be optimized for the best value in a range of 1/2 of an ATR to 3 ATRs.
The breakeven stop for this system has a floor equal to or greater than the initial risk. For example, if the risk on a trade was $500, we would move our stop to breakeven when our open profits were equal to (or greater than) $500. The breakeven stop could be optimized for values between 75% of the initial risk and two times the initial risk.
Buy my 👉 Trading Systems
Join the 👉 Telegram group
Follow me on 👉 LinkedIn
Follow me on 👉 Twitter
My Broker 👉 Interactive Brokers
If you want discounts for the platform I use contact me privately or buy via this 👉 MultiChart
