The idea
This open-source strategy from 3Commas follows the Turtle playbook: trade in the direction of a channel breakout, then leave on a shorter exit channel. The script does not use a single Donchian. It builds two 20-bar channels, then shifts the second one 20 bars to the right. A trade is taken only when the faster channel breaks and the close is also beyond that slower, shifted channel.
The chart on the publication page is Binance ETHUSDT on the 4-hour timeframe, so this page is filed under ETH. The script is not hard-coded to one symbol and will load on others, but the walkthrough and the image stay with the author’s chart. Percent take-profit is optional and off by default. A later section can send 3Commas webhook alerts; those settings are not part of the entry math.

Indicators
- Channel 1 (default 20): the 20-bar high and low — a standard Donchian, via ta.highest(high, period) and ta.lowest(low, period).
- Channel 2 (default length 20, offset 20): the same 20-bar high/low, then shifted 20 bars, used as confirmation.
- Exit channel (default 10): a 10-bar high/low that ratchets only in the trade’s favor for longs and shorts.
- Breakouts are evaluated on a closed bar: a long, for example, needs the close to cross above the prior bar’s Channel 1 upper band, with barstate.isconfirmed set, so a forming bar cannot fire early.
Entry rules
- The default side is both long and short. The Strategy input can restrict that to long only, short only, or no orders at all.
- Long: the close crosses above the previous Channel 1 upper band, the close is also above the previous Channel 2 upper band, and the script’s inbuy flag is still false.
- Short: the close crosses below the previous Channel 1 lower band, the close is also below the previous Channel 2 lower band, and insel is still false.
- If Use Custom Test Period is on, only signals inside that window reach the Strategy Tester. The input is off by default.
- Tester orders are named Buy and Sell. The default size is 1% of equity, with 0.1% commission and a slippage setting of 5.
Exits and position sizing
- The long exit line is the higher of its previous value and the current 10-bar lowest low, so it only tightens. The short exit line only moves down.
- A confirmed close back through the long exit line closes Buy with strategy.close; a close through the short exit line closes Sell.
- Percent take-profit is off unless you enable Take Profit %. The limit is then close × (1 ± percent) from the signal bar, default 20%, submitted with strategy.exit. The stop argument is explicitly na, so that exit does not also act as a stop.
- The chart plots average entry, the exit line, and the optional target. The two Donchian plots are hidden by default (display.none); turn them on in the style panel if you want to see the channels.
- The 3Commas Integration block can fire alert() messages for entries and exits. Leaving those fields blank does not change how the strategy places orders on the chart.
Inputs (source defaults)
| Input | Default | Purpose |
|---|---|---|
| Period Channel 1 | 20 | Faster Donchian length used to trigger the breakout |
| Period Channel 2 | 20 | Length of the confirmation channel |
| Offset | 20 | Bars the confirmation channel is shifted |
| Period Exit | 10 | Length of the trailing exit channel |
| Strategy | Long & Short | Order direction: both, long only, short only, or none |
| Take Profit % | Off / 20 | Optional percent target; disabled by default |
| Use Custom Test Period | Off | Restrict the tester to a date range |
| Test Start / End | 2013-01-02 / 2030-12-02 | Default window if the custom period is enabled |
| 3Commas Integration | Optional | Alert text and toggles for 3Commas webhooks; not an entry filter |
Things to know before using it
- The strategy sets calc_on_every_tick=true, and also enables use_bar_magnifier and fill_orders_on_standard_ohlc. Entries wait for barstate.isconfirmed, but tester fills can still differ from a close-only script.
- inbuy and insel are script-side flags, cleared after an exit or a take-profit hit. They usually track strategy.position_size, but they are not the broker position.
- The publication text sometimes calls this an indicator; the source uses strategy(). The channels are hidden by default, which can make the chart look like it has no bands.
- The default size is 1% of equity, which is conservative for watching signals. Larger size scales up both swings and drawdowns.
- This page explains the rules and inputs. It is not an assessment of 3Commas bots or any copy-trading service.
Installing it on TradingView
- Download the .pine file from Coinpred (active membership required, see below), or check the original page for the latest version.
- Open the Pine Editor on TradingView, create a blank script, paste the full source and save.
- Click Add to chart. To match the author image, start with ETHUSDT on the 4-hour timeframe.
- Turn on Upper/Lower Channel 1 and Channel 2 if you want the bands visible, then decide whether to enable the percent target.
- Study signals and fills in the Strategy Tester before setting alerts. Past results do not guarantee future returns.
About backtest figures
Source, license and version
- Source: https://www.tradingview.com/script/9qFCuXqF-3Commas-Turtle-Strategy/
- Author: 3Commas. Source version 1.0 (Pine v6), scriptAccess=open_no_auth.
- License: Mozilla Public License 2.0. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified full source.
- Members can download the .pine file on this page to study the rules. Judge the risk yourself, and follow your venue’s rules.