Strategy · Pine Script v4 · On the chart

Greeffer's Donchian Channel Strategy

by modster

This strategy draws a Donchian channel with a very long default period of 1440 bars, its midline and a 250-period simple moving average.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code78
Settings7inputs
LicenceMIT
Last update4 years ago11 Feb 2022

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 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

78 lines of Pine Script v4 from donchian-channels/greeffers-donchian-channel-strategy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

greeffers-donchian-channel-strategy.pine
// Greeffer's Donchian Channel Study
// @version=4
//@Greeffer
// S T U D Y
// study(shorttitle="Greeffer's Study", title="Greeffer's  Donchian Channel Study", overlay=true)

// S T R A T E G Y 
strategy(
     "Greeffer's Donchian Channel Strategy",
     "Greeffer's Strategy",
     overlay=true, 
     pyramiding=10,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=150,
     initial_capital=5000,
     commission_type=strategy.commission.percent,
     commission_value=0.1,
     margin_long=1./30*50, 
     margin_short=1./30*50
     )

// I N P U T S
sma = input(title="sma", type=input.integer, defval=250)
symbol = "BTCUSDT" //symbol = "ETHUSDT"
var upperAmount = 0.001
var lowerAmount = 0.001
crossMiddle = false
volumeMA = input(title="volume ma period", type=input.integer, defval=200)
volMultiplyer = input(title="volume multiplyer", type=input.integer, defval=3)
donchianupper = input(title="upper donchian channel", type=input.integer, defval=1440)
donchianlower = input(title="lower donchian channel", type=input.integer, defval=1440)
takeprofit = input(title="take profit", type=input.float, defval=1000.00, step=0.01)
stops = input(title="stops", type=input.float, defval=500.00, step=0.01)

// V A R S
short = false
long = false
stopshort = close + stops
stoplong = close - stops

//----------------------?
//symbol = syminfo.ticker

// D O N C H I A N   C H A N N E L S
lower = lowest(donchianlower)
upper = highest(donchianupper)
middle= (upper-lower)/2+lower
plot(middle, title='Middle', color=color.green, linewidth=1)
plot(upper, title='Upper', color=color.orange, linewidth=1)
plot(lower, title='Lower', color=color.orange, linewidth=1)

// S M A
plot(sma(close,sma))

// V O L U M E
volMA = sma(volume, 200)
//upperVol = highest(volume, 200)
upperVol = volMA*volMultiplyer

// E N T R Y / E X I T   C o n d i t i o n s 
// S h o r t
if high>=upper and volume>upperVol
    short:=true
else 
    short:=false

// L o n g :
if low<=lower and volume>upperVol
    long:=true
else
    long:=false

// O R D E R S :
TP = takeprofit * 100
strategy.entry("short", strategy.short, limit=upper, stop=1, when=short)
strategy.entry("long", strategy.long, limit=lower, stop=1, when=long)
strategy.exit("tp-short", from_entry="short", profit=TP)
strategy.exit("tp-long", from_entry="long", profit=TP)

Overview

Greeffer's Donchian Channel Strategy places limit orders to sell at the upper band after a high touches it and to buy at the lower band after a low touches it, when volume exceeds a multiple of its moving average. A fixed-distance take profit is attached. Pyramiding of up to ten entries is allowed and no stop loss is applied.

Details

Published by

modster on GitHub

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Breakout, Mean reversion, Volume

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
smaint250sma
volume ma periodint200volumeMA
volume multiplyerint3volMultiplyer
upper donchian channelint1440donchianupper
lower donchian channelint1440donchianlower
take profitfloat1000.00takeprofit
stopsfloat500.00stops
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.

Similar Pine Scripts

13 stars

This strategy identifies volume-based rebound signals on the price chart. It detects three or more consecutive lower volume candles followed by a higher volume candle, with price remaining lower from the start of the volume sequence, signaling potential long e

Strategy v5 VolumeBreakout
Updated 1 year ago · None stated GitHub repository of Ruckard Voladder D002

DOT BTC Binance 1m

by tseitz
1 stars

This strategy trades the DOT/BTC pair on a one-minute chart. It plots the VWAP of the close and two offset VWAP bands on the price chart. It opens a long when the open is above the upper band and a short when the open is below the lower band, then closes those

Strategy v4 VolumeBreakout
Updated 4 years ago · None stated GitHub repository of DOT BTC Binance 1m

BB and KC Strategy

by hasnocool
106 stars

This strategy identifies breakout momentum by combining Bollinger Bands and Keltner Channels with volume confirmation. It opens long positions when the upper Keltner Channel crosses above the upper Bollinger Band and volume exceeds its moving average. Converse

Strategy v5 Volatility & bandsBreakout
Updated 2 years ago · GPL-3.0 GitHub repository of BB and KC Strategy
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 5 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers