1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
90 lines of Pine Script v5 from 13_Donchian_Channel/13_Donchian_Channel.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Donchian Channel - Turtle Trading enters long when the price breaks above the upper entry channel and short when it breaks below the lower channel, with an optional filter that skips signals following a winning trade. Position sizing allows pyramiding up to a set limit every 0.5 ATR in profit. Positions exit either when hitting an ATR-based stop or upon breaking the shorter exit channel. It plots both entry and exit channels directly on the price chart.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Entry Channel Length
int
20
entryLength
Exit Channel Length
int
10
exitLength
Skip Entry if Previous Trade Won
bool
true
useFilter
ATR Length (Position Sizing)
int
20
atrLength
ATR Multiplier for SL
float
2.0
atrMult
Use Exit Channel as Trailing Stop
bool
true
trailByExit
Max Pyramid Entries
int
3
pyramidMax
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr
This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos
The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window. When price breaks out of the static channel for a confirmed number of
This strategy executes trades based on crossovers between a 12-period and a 26-period exponential moving average (EMA). Long positions can be filtered by pivot resistance breakouts and RSI boundary ranges. For trade management, it provides two configurable par
This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the
This strategy enters long or short on the price chart when price is on the correct side of a 200-period EMA, MACD agrees, RSI is not at the opposing extreme, ADX exceeds a threshold, volume beats a 20-bar average, and close breaks the recent high or low. A tim