Script Explained

Script:                RTT ATR EnvelopesEx

Back to Catalogue

Purpose:            Draw two bands around an EMA of “typical” daily prices.
Add recent Low/High levels suggesting stop-loss or trailing exit stops; these levels can be adjusted, depending on when the trade was entered into.
The Central line is calculated from the day’s Pivot Points, of which an Exponential Moving Average is calculated. Outer and Inner bands are then drawn at a distance of selected multiples of Average True Range (ATR) above and below the Pivot EMA.
The recent Lows and Highs of each band are indicated at the right-hand side of the chart towards the price scale.

Setting the global chart parameters to "calculate visible points only" will save time because the script calculates and draws only for the days that are visible in the current window. (see "Parameters" below).
If you zoom out and wish to expand the plot, right-click inside the window, select the script's Properties, and click "OK". That will redraw the plot for the larger time frame.

Please note that plotted scripts work on any time scale. When using different scales, replace "day" by "tick" (month, week, hour, ...) as appropriate.

The Highs and Lows of ATR bands are commonly used to suggest trailing stops for open trades. With Trinity, I have also found that the opposite band can suggest a safe entry level.

For Long trades, it works like this: After receiving an entry signal - say, Trinity's MACD crosses zero on good volume - we wait for the price to cross (or close) above the Lowest point of the pink band immediately preceding the signal day, ie the day that Trinity event happened.
If my entry rule includes a safe entry level (eg FTFF level broken or 4th attempt of breakout successful), that rule is given precedent, resulting in a later (higher, but safer) entry after the trend reversal has been well enough confirmed. Otherwise, I'll use the most recent Low of the pink envelope (i.e. the Low that's closest to the entry signal) as my entry level.

Once in the trade, we watch the inner (lime-green) line and pick for our stop level the highest point since entering. We never move the stop down, only higher. As soon as the price falls below the stop level, we sell.
Alternative: "stop on a closing basis", i.e. We wait if the Close is still below the stop level. This may only be suitable for traders who can watch the Market during the day; but it avoids being stopped out unnecessarily in an Intraday "stop raid".

As the trade continues and the stop moves into profit territory (i.e. above our entry price) we may use the outer band. As the first chart example shows, such a strategy is more forgiving and tends to keep us longer in the trade. We're letting the profit ride, even though retracements may later erode some of the profit margin.

The program displays the current Highs of inner and outer stop levels as lines in the right-hand gap between last day and price axis. The first parameter, Days in Trade, tells the program where to start. In the attached example, we started 4 days ago after a retracement. Running the calculation from the Left of screen, the stop lines would refer back to an earlier High, indicating a profit stop for trades we may have taken in the past.
Setting the Days in Trade to zero (0) will take the extremes from the entire range, thus working exactly like the original "ATR Envelopes".

Note also that the default parameters are suggestions only. For some stocks, I found an initial multiple of 0.8 will conserve capital; as the stock moves up, it will quickly get into profit, where I may increase the bandwidth to a multiple of 2.4. Other authors use 1.5 and 3 or 2 and 3.

The markers on the right indicate the most profitable trading levels. They also provide feedback as to whether the chosen parameters are a suitable "fit" for a particular stock. Wherever possible, I try and determine (from history) how a stock moves inside a particular envelope. Knowing this - as part of the stock's DNA - helps check the suitability of any actual strategy.

For Short trades, the roles of red and green lines are reversed inasmuch as we start short-selling at the green (or grey) level, watching the price fall till it rises back above pink or red, where we stop out by buying back.

Unlike other trailing stop methods, e.g. Parabolic SAR, Candle count-back, etc, which apply a fixed parameter (acceleration, number of days) to determine an exit level, the ATR Envelopes base their suggestion on the latest trading behaviour: volatility and typical price. This allows us to follow the trend more closely than a fixed rule "same size fits every day".
The only downside that I have found with this approach occurs in "blow-off" moves, where a price rallies at an increasing gradient, following a parabolic curve. Usually, such rallies reverse - often very violently and gapping down - as soon as no higher low can be mustered. But with volatility at its extreme, the stop level has moved far away from "the action", thus risking a large amount of temporary gains.
In cases of such parabolic moves, I have found a very effective compromise: Drawing successively steeper trendlines, I exit as soon as the steepest gradient is broken. This overrides any trailing stop. However, taking profit is by no means a signal to immediately reverse the trade. I only short a falling stock once it has broken the latest "Sell" level. (see second chart below)

Additional Tip: The range between entry and exit levels can also be used to limit the inherent risk of a trade. Let's say we do not wish to expose more than $600 in a trade of CTX. Entry at pink level ($19.45); current stop at green ($18.85); risk $0.60. $600 divided by 60c means we can "afford" to buy 1,000 shares; a disciplined trade will then risk no more than our limit. (scroll down to CTX chart)
PS: If you follow this trade, you can verify a stop-loss exit ("exit at Close below green High") was triggered on January 25 when CTX closed at $19.13. The next Trinity trade from March 1 ($17.45) more than made up for it.

Back to Catalogue

References:        Pivot Points
IncredibleCharts: ATR
IncredibleCharts: Stop loss

Back to Catalogue

Parameters:       Days in Trade = how long ago did we enter this trade; stop levels are calculated since then
MA Period = period, over which MA is calculated
ATR Period = period, over which ATR is calculated
Outer Band = multiple (ATRs) for outer band
Inner Band = multiple (ATRs) for inner band

Global (File) Parameter Setting for Chart to draw plotted scripts faster:

Back to Catalogue

Example: Entry based on candle

Back to Catalogue

Example: Long and Short trades, single (inner) band only

Back to Catalogue

Example: Risk calculation

Back to Catalogue