Strategy vault / Trend following
Andrew Abraham Trend Tracking Strategy
The Trend Tracking strategy was proposed by Andrew Abraham in an article titled "Trading the Trend" published in Technical Analysis of Stocks & Commodities magazine in September 1998. It uses the moving average true…

Overview
The Trend Tracking strategy was proposed by Andrew Abraham in an article titled "Trading the Trend" published in Technical Analysis of Stocks & Commodities magazine in September 1998. It uses the moving average true range and highest and lowest prices to determine the price trend and trade in the direction of the trend.
Principles
The strategy first calculates the 21-day average true range avgTR. Then it calculates the 21-day highest price highestC and lowest price lowestC. Next, it calculates the upper rail hiLimit, which is the highest price minus 3 times avgTR; and the lower rail loLimit, which is the lowest price plus 3 times avgTR. When the closing price exceeds the upper and lower rails, their values are taken as the reference price ret, respectively. When the closing price is higher than the reference price, go long; when lower, go short.
Advantages
The main advantages of this strategy are:
- Using average true range to calculate the channel can dynamically capture market volatility.
- Combining highest and lowest prices to determine trend direction avoids being misled by oscillating markets.
- The logic is simple and clear, easy to understand and implement.
- It can trade according to the trend and avoid frequent opening positions in oscillating markets.
Risks
There are also some risks with this strategy:
- More false signals will occur in oscillating markets. This can be reduced by optimizing parameters.
- Unable to determine trend reversal points, risk of loss exists. Other indicators can be combined to judge trend reversal.
- Improper parameter optimization may lead to overtrading or false signals. The stability of parameters needs to be tested carefully.
Improvement
Some ways to improve this strategy:
- Optimize the moving average period to find the best parameter combination.
- Add stop loss to control single loss.
- Combine volatility indicators to determine market conditions and avoid trading in oscillating markets.
- Add trend judgment indicators to identify trend reversal points and reduce probability of losses.
Conclusion
In summary, the Trend Tracking strategy is a simple and practical trend trading strategy. It uses price channels to determine trend direction and avoid being trapped in oscillating markets. But there are still some risks, and further optimizations are needed to improve stability. It is suitable for investors with some trading experience.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 21 | Length |
| v_input_2 | 3 | Multiplier |
| v_input_3 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2024-01-07 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 12/01/2017
// This is plots the indicator developed by Andrew Abraham
// in the Trading the Trend article of TASC September 1998
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Trend Trader Strategy", overlay = true)
Length = input(21, minval=1),
Multiplier = input(3, minval=1)
reverse = input(false, title="Trade reverse")
avgTR = wma(atr(1), Length)
highestC = highest(Length)
lowestC = lowest(Length)
hiLimit = highestC[1]-(avgTR[1] * Multiplier)
loLimit = lowestC[1]+(avgTR[1] * Multiplier)
ret = iff(close > hiLimit and close > loLimit, hiLimit,
iff(close < loLimit and close < hiLimit, loLimit, nz(ret[1], 0)))
pos = iff(close > ret, 1,
iff(close < ret, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(ret, color= blue , title="Trend Trader Strategy")Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-08. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Andrew-Abraham-Trend-Tracking-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- ATR Dynamic Profit Target and Stop Loss StrategyPine Script · Trend following · 1d
- ATR Dynamic Trend Following and EMA Crossover Trading StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- ATR and T3 Moving Average StrategyPine Script · Trend following · 5m
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h