Thinking Stuff's ATM

Automated Trading Machine (ATM) makes it simple to remove fear and greed from your trading. Automated trading is no longer just for the rich or nerdy. Our revolutionary software runs on your computer, using your trading rules, but none of your emotions. There's just one requirement - you know how to use a mouse.  Learn more...

Thinking Stuff's ATE

Automated Trading Execution (ATE) is where we run your trading systems for you on our servers. Your system can be exported from ATM, or written in plain English and we'll make it for you. We'll even backtest and suggest improvements if you want us to. This service essentially automates your automated trading.  Learn more...

Thinking Stuff's Groups

Join a group of like-minded individuals, and help each other to trading success. Once you join a group, you will have access to that group's trading systems, ideas, and feedback. And please contribute your own knowledge as much as possible. Or contact us to start your own group.  Learn more...

Example trading systems

Video: Backtesting

This tutorial demonstrates how to create a trading system, and then backtest that system using historical price bars.

It assumes:

  1. You started ATM and opened a settings file.
  2. That settings file already has some price bars in it.
  3. ATM is sitting there ready to go.

This tutorial does these things:

  1. Creates a trading system.
  2. Creates a backtest configuration entry.
  3. Runs the backtest.
  4. Views the chart. We decide how the system might be made better.
  5. Edits the trading system.
  6. Runs the backtest again.
  7. Views the chart again to see if we did actually make it better or not.

There are several objective ways of determining if a price is trending or ranging, and the trading system we create in this tutorial was inspired by the Two Bollinger Bands method. For a stop loss we use the Chandelier Stop described in more detail here.

Click here to watch the video, and use the browser's back button to come back. Or click here to open in a new window.
 

See also:

%b System #1 With Chandelier Stop

This is the same as %b System #1 except we replaced the trailing stop with the Chandelier method. I've heard of the Chandelier stop before in Dr.Alexander Elder's "Come Into My Trading Room". I came across it again in the Oanda forums, specifically this post.

Here's what a user called EZCurrency said (HHV = highest high value, LLV = lowest low value, ATR = average true range):

For a trailing stop for a long, I use HHV(H,24)-3.5*ATR(24) on an hourly chart. This is the highest high value of the past 24 hrs, then subtract 3.5 times the average range of the past 24 hrs. This accounts for the volatility. Plot it and you will see it is an excellent trailing stop for most pairs!

Another user, Gouranga, then came up with a possible improvement:

One can combine this with a LLV(n) (eg. Long Trade) and take the higher trailer of the two. LLV(n) trailer locks in profit when market consolidates. While (HHV - ATR) locks in profit when market trends. So, you get the best of both mkt conditions.

We provide both of these indicators in ATM - what is described in the first quote is referred to as the "Chandelier Stop", and that described in the second quote is referred to as the "Better Chandelier Stop" (whether it is actually better or not is subject to some backtesting).

But this is a good time to demonstrate exactly what happens when you enter more than one value, so forget that we made the "Better Chandelier" for a second. What ATM will do with the trading system below, for the longs anyway, is calculate both the Chandelier Stop and the lowest low. Then it will take the higher of those two values. For shorts it will take the lower of the Chandelier Stop and the highest high.

The basic theory of using the ATR in order to calculate the stop loss, is that it's adaptive to the current market conditions. During volatile periods the stop will be placed further away, and during less volatile periods the stop will be brought closer to the current price. Basically it adjusts the amount of wiggle room based on the volatility.

In very rough testing, we used 5-Minute bars, 720 for the Bollinger period, which is kind of big, and the normal 2 standard deviations above and below. The period for the ATR is 24.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is below X Bollinger %b 0.1
Entry Values   Price where %b would equal X 0.1
Initial S/L Values   Long Chandelier Stop  
Initial S/L Values   Minimum(LOW, 24)  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Values #1   Long Chandelier Stop  
S/L Mgmt Values #1   Minimum(LOW, 24)  
Short Entry Rules Line 1 is above X Bollinger %b 0.8
Entry Values   Price where %b would equal X 0.8
Initial S/L Values   Short Chandelier Stop  
Initial S/L Values   Maximum(HIGH, 24)  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Values #1   Short Chandelier Stop  
S/L Mgmt Values #1   Maximum(HIGH, 24)  

 

%b System #1

Bollinger %b is a single line whose value is determined by where the closing price is in relation to the upper and lower Bollinger lines.

When the close is exactly at the lower line, %b equals 0. Below the lower line, %b is negative. When the close is exactly at the upper line, %b equals 1. When it's exactly in the middle, %b equals 0.5. And so on.

It's very rare for %b to be lower than -0.3, or higher than 1.3.

The way Bollinger Bands are constructed, the price moves from the lower band, to the upper band, and back to the lower band. The problem is that the Bands aren't static. Just because the price moved from the lower band to the upper band, it doesn't necessarily mean that the price is rising - the upper band might have come down to meet the falling (or stagnating) price.

Anyway, here's a system which attempts to use this knowledge. In very rough testing, we used 5-Minute bars, 720 for the Bollinger period, which is kind of big, and the normal 2 standard deviations above and below.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is below X Bollinger %b 0.1
Entry Values   Price where %b would equal X 0.1
Initial S/L Values   CLOSE * 0.997  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Values #1   CLOSE * 0.997  
Short Entry Rules Line 1 is above X Bollinger %b 0.8
Entry Values   Price where %b would equal X 0.8
Initial S/L Values   CLOSE * 1.005  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Values #1   CLOSE * 1.005  

 
We know that the price oscillates between one of the outer Bollinger lines and the other. So when the price falls down near the bottom one, we set a trap waiting for it to start heading back to the top one. When the price does start rising again, the limit order is taken up, and a trailing stop loss is kept at 0.3% below the close.

That's setting the stop loss pretty close to the price, but we were using 5-Minute bars which don't need as much wiggle room as Daily bars would.

Similarly, when the price rises up near the upper Bollinger line, we set our trap this time waiting for it to come down.
 

Maoxian Trading For Dummies With Trailing Stop

This adds a trailing stop to Maoxian's Trading For Dummies system. (One of) his trailing stop techniques is described in the very last paragraph of this page:

One simple way to trail a stop is to place it below the last "up" bar... an "up" bar is simply a bar with a higher high and a higher low than the previous bar.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is equal to Line 2 VOLUME MAX(VOLUME, 20)
Entry Rules Line 1 is above Line 2 Upper Bollinger Line (10, 2) Upper Bollinger Line (50, 2)
Entry Rules Line 1 is falling HIGH  
Entry Rules Line 1 is above Line 2 CLOSE EMA(20)
Entry Rules Line 1 is below X Hours part of the bar's start date 13
Entry Values   HIGH  
Initial S/L Values   LOW  
S/L Mgmt Rules #1 Line 1 is rising LOW  
S/L Mgmt Rules #1 Line 1 is rising HIGH  
S/L Mgmt Values #1   LOW  
T/P Mgmt Rules #1 Line 1 is above X Hours part of the bar's start date 17
T/P Mgmt Values #1   Exit At Market  
Short Entry Rules Line 1 is equal to Line 2 VOLUME MAX(VOLUME, 20)
Entry Rules Line 1 is below Line 2 Lower Bollinger Line (10, 2) Lower Bollinger Line (50, 2)
Entry Rules Line 1 is rising LOW  
Entry Rules Line 1 is below Line 2 CLOSE EMA(20)
Entry Rules Line 1 is below X Hours part of the bar's start date 13
Entry Values   LOW  
Initial S/L Values   HIGH  
S/L Mgmt Rules #1 Line 1 is falling HIGH  
S/L Mgmt Rules #1 Line 1 is falling LOW  
S/L Mgmt Values #1   HIGH  
T/P Mgmt Rules #1 Line 1 is above X Hours part of the bar's start date 17
T/P Mgmt Values #1   Exit At Market  

 

Objective Ways Of Determining Trending Vs Ranging

How often have you heard "the trend is your friend"? Or "always trade with the trend"? Common wisdom has it that knowing the direction of the trend is very important. Moreover, not all indicators work in all trading conditions. Some work very well in trending markets, others work well in ranging markets. The ones that work well in trending markets normally die painful deaths in ranging markets, and vice versa.

So you've got 3 kinds of markets - up, down, sideways. Up and down = trending, sideways = ranging. More volatility = trending, less volatility = ranging. These market conditions are often easy to spot in hindsight with the naked eye. But for automated trading you need objective, measurable, and repeatable rules which work in real-time.

This post hopes to list such indicators. If you know of others or other ways to use them, you are free to edit this wiki entry and add them to the list for the benefit of your fellow traders. Or send us an email and we'll add it for you.

Just as no indicator can give 100% correct trading signals, so to do these indicators sometimes give false readings. You should experiment and backtest to find the best one for you.
 

Directional Movement Index

+DI, -DI, and ADX are part of the Directional Movement Index group of indicators.

ADX measures the strength of a trend. A larger value means the market is trending; a lower value means ranging. Where is the cut-over point? This depends on the symbol and time-frame you are trading with, so backtest to find the value that works for you. 25 seems like a good starting point. I have also read that below 20 means ranging, above 30 means trending, and values between 20 and 30 are either or none.

+DI and -DI determine the direction. From Investopedia:

When the +DI is above the -DI, prices are moving up, and ADX measures the strength of the uptrend. When the -DI is above the +DI, prices are moving down, and ADX measures the strength of the downtrend.
 

One Moving Average

If a moving average of decent length (say 20+) is rising, you can say there is an uptrend. If falling then there's a downtrend.

Using one moving average is better than nothing, but if using one is good, surely using two is better.
 

Two Moving Averages

Use a combination of faster and slower moving averages, say SMA(10) and SMA(50). If the faster average is above the slower, that's an uptrend. If the faster is below the slower, that's a downtrend.

The distance between the 2 averages gives an indication of the strength of the trend. The MACD indicator measures this, so a rising MACD means a stronger trend.
 

Three Moving Averages

If two moving average is better, maybe using 3 will be fantastic. For example, moving averages of period 5, 10, and 20:

  1. When SMA(20) is above SMA(10) is above SMA(5) - that's a downtrend.
  2. When SMA(20) is below SMA(10) is below SMA(5) - that's an uptrend.
  3. When they are not in that nice order, the market is ranging.
     

Two Bollinger Bands

Use a combination of a faster and slower Bollinger Bands. While the faster Bollinger Bands are contained within the slower, it's a ranging market. Otherwise it's trending.

Normally in this trend it's just one of the faster Bollinger lines outside the slower. If the faster upper Bollinger line is above the slower, that's an uptrend. If the faster lower Bollinger line is below the slower, that's a downtrend. If it's both, then that price is about to move big time! (Or the price has already done it's big jump and now it's too late. Cest la vie).
 

Bollinger Bandwidth

A Bollinger Band's two outer lines flare outwards when prices are volatile, and narrow when they aren't. The Bollinger Bandwidth indicator actually measures that distance, so a rising Bandwidth means higher volatility, and that means a higher possibility that the market is trending. Or you could say any Bandwidth value over X is fine. Or perhaps when the Bandwidth indicator is above its moving average.
 

High-Low Range

The High-Low range gives a value indicating how long a candle is. You can use the average or maximum high-low range - if rising then the bars are getting progressively longer. Longer bars means more volatility.
 

True Range

The High-Low range checks just 1 bar, whereas the True Range checks a bar and the bar next to it. Again, the average or maximum true range can be used as a measure of volatility.
 

Ichimoku Kinko Hyo

We added this indicator for a customer but don't really know how to use it yet. Apparently it's good for this kind of thing. Here is Investopedia's explanation. And here is another random link Google gave us.
 

Maoxian Trading For Dummies

From the Chairman Maoxian website, more particularly one of his archive pages.

On that archive page, he lists quite a number of trades under the "Trading for Dummies, Q&A Series" banner. While he does not specify his trading rules explicitly, I'm pretty sure that the intention of providing all those examples was for you to look at the charts and work out his system.

Here's what I came up with:

  • On 30-Minute chart.
  • Unusually active (more volume than normal).
  • Very volatile. Perhaps a gap.
  • Wait for "pullback", which means lower high in uptrend, higher low in downtrend.
  • "Uptrend" means prices above EMA. "Downtrend" means prices below EMA.
  • Trade must be before lunch-time. The noon bar is the last bar to make calculations off. Otherwise finish for the day.
  • Set entry at high of pullback bar (for long trades).
  • Set initial stop-loss at low of pullback bar (for long trades).
  • If next bar pulls back further, reset entry and initial stop-loss.
  • Exit at the end of the day (or could keep half if you want).
  • One trade per stock per day only (i.e. don't get back in if stopped out).

Please keep in mind that this system is meant for trading shares. Some adaptation is required to make it usable for trading currency. For example, currency does not have volume. Further, currency trading is 24/7, 5.5 days per week. The rule to stop trading at noon or at the end-of-day needs to be dropped or adapted.

There are also a couple of things which need to be changed into "purely objective trading systems" language. For example "unusually active", and "very volatile".
 

Unusually active

This applies to the volume. If the system is to trade in forex then just remove this rule. Here are a couple of possibilities for turning "unusually active" into something that a computer can use:

  • Current bar's volume is more than a multiple of the average volume.
  • Current bar's volume is the highest of the last 20 bars.
  • Rising volume for 2 or 3 bars in a row.
  • All of the above combined.

I think I'll go with the second option.
 

Very volatile

There's a special post about this. I'm going to use the "Two Bollinger Bands" method.

Here's what I came up with:
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is equal to Line 2 VOLUME MAX(VOLUME, 20)
Entry Rules Line 1 is above Line 2 Upper Bollinger Line (10, 2) Upper Bollinger Line (50, 2)
Entry Rules Line 1 is falling HIGH  
Entry Rules Line 1 is above Line 2 CLOSE EMA(20)
Entry Rules Line 1 is below X Hours part of the bar's start date 13
Entry Values   HIGH  
Initial S/L Values   LOW  
T/P Mgmt Rules #1 Line 1 is above X Hours part of the bar's start date 17
T/P Mgmt Values #1   Exit At Market  
Short Entry Rules Line 1 is equal to Line 2 VOLUME MAX(VOLUME, 20)
Entry Rules Line 1 is below Line 2 Lower Bollinger Line (10, 2) Lower Bollinger Line (50, 2)
Entry Rules Line 1 is rising LOW  
Entry Rules Line 1 is below Line 2 CLOSE EMA(20)
Entry Rules Line 1 is below X Hours part of the bar's start date 13
Entry Values   LOW  
Initial S/L Values   HIGH  
T/P Mgmt Rules #1 Line 1 is above X Hours part of the bar's start date 17
T/P Mgmt Values #1   Exit At Market  

 
I kept the rules in order of the English description at the start of this post. In this case there is a one-to-one mapping. Except for the last specification - only 1 trade per day. There's no rule in ATM that handles this. But there are the "No Trading" settings. And amongst those there is the "Allow up to and including X long trade(s) in a row" option (also for short). Set these to 1. So one long trade will be allowed, one short trade will be allowed, and then this system will stop trading.
 

Holy Grail Trading System

This system was found on the Chairman Maoxian website, more particularly at this page.

He credits a book called "Street Smarts", written by Linda Bradford Raschke.

Here's how it is described:

The basic idea for this set-up is that when the Average Directional Index (ADX) is high and price drops back to the 20 period exponential moving average (EMA), you should look to buy and target the previous swing high as your exit.

Obviously this technique can be applied to the short side as well: High ADX, price pulls back to the 20 EMA from below, get short and target the prior swing low.

A bit of tinkering is required to complete this system (in terms of what I think of as a "complete" system). For example, that paragraph uses the words "...you should look to buy..." But when creating purely objective trading systems, a specific value of where to enter needs to be written out.

Here's what I came up with:
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is above X ADX 25
Entry Rules Line 1 is above Line 2 LOW
Bar offset 1
EMA(20)
Bar offset 1
Entry Rules Line 1 is below Line 2 LOW EMA(20)
Entry Rules Line 1 is rising EMA(20)  
Entry Rules Line 1 is below Line 2 HIGH + 0.0010 Current Bar Swing High
Entry Values   HIGH + 0.0010  
Initial S/L Values   LOW - 0.0050  
Initial T/P Values   Current Bar Swing High  
Short Entry Rules Line 1 is above X ADX 25
Entry Rules Line 1 is below Line 2 HIGH
Bar offset 1
EMA(20)
Bar offset 1
Entry Rules Line 1 is above Line 2 HIGH EMA(20)
Entry Rules Line 1 is falling EMA(20)  
Entry Rules Line 1 is above Line 2 LOW - 0.0010 Current Bar Swing Low
Entry Values   LOW - 0.0010  
Initial S/L Values   HIGH + 0.0050  
Initial T/P Values   Current Bar Swing Low  

 
Actual entry method and stop loss placement methods are not given on the Maoxian webpage. So I chose arbitrary values, as this is just a demonstration anyway. For longs, I put the stop loss 50 pips below the low, and the entry price is 10 pips above the high.

Why that entry point? Because this trading technique is to (I guess) find a good buying opportunity in an established uptrend. So to confirm the uptrend, I make sure that the EMA(20) is rising. And to make sure it's just a minor pullback and not a complete reversal, I put the entry price above the high. So the price has to push higher after initially falling back and triggering our entry rules.

The last thing to note about this system is the placement of the take profit. For longs, the take profit wants to be at the current bar swing high. So I just make sure that this take profit is actually going to be placed above the entry point of high + 10 pips. If not then there's no reason to trade.
 

Three Ways To Exit

There are 3 ways to exit a trade:

  1. stop loss is taken out
  2. take profit is hit
  3. exit at market

This example will demonstrate all three. For the Longs there will be a stop loss set 50 pips below the low; we will trail that stop loss at 50 pips below the low; a take profit will be set 75 pips above the high; and if we get 2 consecutive lower lows then we will exit at market.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is above X MACD Histogram 0 (zero)
Entry Rules Line 1 is above X RSI 70
Entry Values   Enter At Market  
Initial S/L Values   LOW - 0.0050  
Initial T/P Values   HIGH + 0.0075  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Value #1   LOW - 0.0050  
S/L Mgmt Rules #2 Line 1 is falling LOW
Bar offset 1
 
S/L Mgmt Rules #2 Line 1 is falling LOW  
S/L Mgmt Value #2   Exit At Market  
Short Entry Rules Line 1 is below X MACD Histogram 0 (zero)
Entry Rules Line 1 is below X RSI 30
Entry Values   Enter At Market  
Initial S/L Values   HIGH + 0.0050  
Initial T/P Values   LOW - 0.0075  
S/L Mgmt Rules #1 Line 1 is above X CLOSE 0 (zero)
S/L Mgmt Value #1   HIGH + 0.0050  
S/L Mgmt Rules #2 Line 1 is rising HIGH
Bar offset 1
 
S/L Mgmt Rules #2 Line 1 is rising HIGH  
S/L Mgmt Value #2   Exit At Market  

 
We used the stop loss management rules and values #2 here, but you can use any of stop loss management #1-#9 and take profit management #1, #2 to exit at market.
 

Using An Overlay For The Entry Price

To keep things simple, normally in these examples we just explain in terms of Long trading. And that will continue here. But also for the purposes of keeping things simple, we also normally just use "Enter At Market" for the entry values - as soon as the entry rules are true, ATM will immediately open a trade using a market order.

ATM can also place limit orders, which allow a slightly different trading style. Here's an example of how they are different:

  • open a long trade if the close is above the moving average
  • open a long trade as soon as the price hits the moving average

The first style lends itself to market orders. A new price bar comes along, we do the moving average calculation, and if the CLOSE is above that average then we open a trade.

The second style lends itself to limit orders. It's kind of like setting a trap. With the current price below the moving average, we place a long limit order at that moving average. While the current price stays below the moving average, we adjust the order so it stays in-line with the moving average. And if the price ever happens to hit the moving average, our trap is sprung, and the broker will automatically turn our limit order into a trade.

So here's an example of the latter. Our entry price is going to be at the moving average. We will set the stop loss 50 pips below that average, and the take profit 75 pips above.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is below Line 2 CLOSE SMA(20)
Entry Values   SMA(20)  
Initial S/L Values   SMA(20) - 0.0050  
Initial T/P Values   SMA(20) + 0.0075  
Short Entry Rules Line 1 is above Line 2 CLOSE SMA(20)
Entry Values   SMA(20)  
Initial S/L Values   SMA(20) + 0.0050  
Initial T/P Values   SMA(20) - 0.0075  

 
Perhaps you see the moving average as a moving resistance level. If so, you wouldn't care so much that the price hits the moving average - you would see that as normal behaviour. If it was acting as resistance then the price would hit the moving average and bounce off. So you would be more interested in the price breaking through the average. In that case use SMA(20) + 0.0010 (or whatever) for the long entry value - the price would have to break through the moving average by 10 pips for the long limit order to be hit.
 

Using limit orders to confirm upward/downward pressure

When explaining about the different scenarios that best suit market orders vs. limit orders, we used this one for market orders: "open a long trade if the close is above the moving average".

Limit orders can also be used here. Instead of entering at market whenever the close is above the average, you can set a limit order to confirm upward pressure.

In our example using market orders, a new price bar comes along, we do the moving average calculation, and if the CLOSE is above that average then we open a trade.

But change the entry value to CLOSE + 0.0010 to use a limit order instead. A new price bar comes along, we do the moving average calculation, and if the CLOSE is above that average then we place a long limit order 10 pips higher than the current price. Only if the price continues to rise a further 10 pips does the trade get opened.

Which method works better? Only backtesting knows the answer.
 

Using An Overlay For The Stop Loss

The simplest stop loss values are something like these (sticking to Longs to keep things simple):

  • LOW - 0.0050 (low minus 50 pips)
  • CLOSE * 0.975 (close minus 2.5%)

That is, just subtract some pips or percent from some part of the price bar. And you can read our simple trailing stop example here.

The example below though, uses a simple moving average of the last 20 bars as the stop loss. And you can use this technique with any overlay. Each bar re-position the stop loss to wherever the overlay happens to be, but only as long as the overlay is rising (again, for longs. For shorts only move it if the overlay is falling).

The basic theory is the same as the simple example, but there is one additional thing to check. You need to make sure that long stop losses are always below the current price, and long take profits are always above the current price. The current price is given to us by the CLOSE.

With the simple example above, the LOW is already below the CLOSE, and then we subtract even more pips. So that figure will always put the stop loss on the correct side of the current price. CLOSE * 0.975 does the same thing.

But overlays can move above or below the price bars. So we can't just blindly move the stop loss to wherever the overlay is - first we need to check that the overlay is still below the current price.
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is above Line 2 CLOSE SMA(20)
Entry Rules Line 1 is above X MACD Histogram 0 (zero)
Entry Rules Line 1 is above X RSI 70
Entry Values   Enter At Market  
Initial S/L Values   SMA(20)  
S/L Mgmt Rules #1 Line 1 is above Line 2 CLOSE SMA(20)
S/L Mgmt Value #1   SMA(20)  
Short Entry Rules Line 1 is below Line 2 CLOSE SMA(20)
Entry Rules Line 1 is below X MACD Histogram 0 (zero)
Entry Rules Line 1 is below X RSI 30
Entry Values   Enter At Market  
Initial S/L Values   SMA(20)  
S/L Mgmt Rules #1 Line 1 is below Line 2 CLOSE SMA(20)
S/L Mgmt Value #1   SMA(20)  

 
A stop loss is never moved to a position of increased risk. So even if the moving average goes lower (which happens often, even in a strong uptrend), the long stop loss won't follow it down.

All good? Well maybe.
 

Wiggle Room

The thing is that we don't know how far away that moving average is from the current price. The two could be 1 pip apart, or they could be 1000 pips apart (well, probably not for a SMA(20), but you get my point).

Using the simple example of the low minus 50 pips, you can always be sure that there will be at least 50 pips between the current price and wherever you move the stop loss to. That 50 pips is your wiggle room - the amount of space that the price is allowed to wiggle about as it hopefully continues its upward journey.

But just using an overlay - there's no way to tell how much wiggle room you're giving the price. As I said - the wiggle room might be just 1 pip or 1000. And you might be fine with that. If not, keep reading.

You could do the same thing as the simple example. Instead of just SMA(20) for the stop loss values, use:

  • SMA(20) - 0.0050

Which says to place the stop loss 50 pips below the SMA(20). But what if you really wanted to both (a) get out of a long trade as soon as that SMA(20) was breached; and (b) ensure there was always plenty of wiggle room? Try this:
 

Direction Rule Type Rule Family Line 1 X / Line 2
Long Entry Rules Line 1 is above Line 2 CLOSE SMA(20) + 0.0050
Entry Rules Line 1 is above X MACD Histogram 0 (zero)
Entry Rules Line 1 is above X RSI 70
Entry Values   Enter At Market  
Initial S/L Values   SMA(20)  
S/L Mgmt Rules #1 Line 1 is above Line 2 CLOSE SMA(20) + 0.0050
S/L Mgmt Value #1   SMA(20)  
Short Entry Rules Line 1 is below Line 2 CLOSE SMA(20) - 0.0050
Entry Rules Line 1 is below X MACD Histogram 0 (zero)
Entry Rules Line 1 is below X RSI 30
Entry Values   Enter At Market  
Initial S/L Values   SMA(20)  
S/L Mgmt Rules #1 Line 1 is below Line 2 CLOSE SMA(20) - 0.0050
S/L Mgmt Value #1   SMA(20)  

 
Now the trade is only opened if there is at least 50 pips between the current price and the moving average. And the stop loss is only moved if there is at least 50 pips between the current price and the moving average.

Which method works better? Only backtesting has the answer.