Indicator · Pine Script v4 · On the chart

Greeffer's Donchian Channel Study

by modster

This indicator plots a Donchian channel with a long default period of 1440 bars, its midline and a 250-period simple moving average on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code80
Settings8inputs
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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

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

greeffers-donchian-channel-study.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
symbol = "BTCUSDT" //symbol = "ETHUSDT"
sma = input(title="sma", type=input.integer, defval=250)
amount = input(title="amount", type=input.float, defval=0.001, step=0.01)
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 period", type=input.integer, defval=1440)
donchianlower = input(title="lower donchian channel period", 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 :
if short==true
    alert(message='{"side":"limitSell","limit":"'+tostring(high)+'","stopPrice":"'+tostring(stopshort)+'","takeProfit":"'+tostring(high-takeprofit)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    // must have hedge mode enabled:
    //alert(message='{"side":"shortHedge","stopPrice":"'+tostring(stopshort)+'","takeProfit":"'+tostring(high-takeprofit)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)

if long==true
    alert(message='{"side":"limitBuy","limit":"'+tostring(low)+'","stopPrice":"'+tostring(stoplong)+'","takeProfit":"'+tostring(low+takeprofit)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    // must have hedge mode enabled:
    //alert(message='{"side":"longHedge","stopPrice":"'+tostring(stoplong)+'","takeProfit":"'+tostring(low+takeprofit)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)

Overview

When a high reaches the upper band, or a low reaches the lower band, on volume above a multiple of its moving average, it sends a JSON alert message with a limit price, stop price, take-profit price and order amount. It is aimed at bot-style alert automation and does not itself place orders.

Details

Published by

modster on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Breakout, Mean reversion, Volume

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

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

SettingTypeDefaultVariable
smaint250sma
amountfloat0.001amount
volume ma periodint200volumeMA
volume multiplyerint3volMultiplyer
upper donchian channel periodint1440donchianupper
lower donchian channel periodint1440donchianlower
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

23 stars

Point-Clip Unified Indicator plots breakout and directional labels on the price chart. It scores volume spikes against a volume average, range or opening-range breaks, optional VWAP or session-anchored VWAP, fast and slow EMA trend, and a higher-timeframe EMA

Indicator v6 BreakoutVolume Repaints
Updated 3 weeks ago · Custom licence GitHub repository of Point-Clip Unified Indicator

ORB Multi-Model Indicator

by Mrshahidali420
16 stars

This indicator plots several New York opening-range breakout models on the price chart and can also show a combined confidence-scored signal. Enabled models include classic Crabel, a five-minute scalper, a standard fifteen-minute breakout, and a gold variant,

Indicator v6 BreakoutSessions & time Repaints
Updated 3 months ago · None stated GitHub repository of ORB Multi-Model Indicator
13 stars

This script identifies and visualizes bullish and bearish order blocks on the price chart. It detects low-volatility consolidation ranges followed by breakout moves accompanied by high trading volume. Users can select between Simple, Relative, or Weighted volu

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of Advanced Order Blocks with Volume

This indicator identifies and plots price compression zones directly on the price chart using multi-module scoring. It measures ATR compression, ADX chop levels, boundary touches, volume dry-up, and historical pivot levels to identify consolidation areas and s

Indicator v6 BreakoutSupport & resistance
Updated 2 days ago · MIT GitHub repository of CoilForge Zones [WavesUnchained]

Nexural ORB

by JasonTeixeira
9 stars

This indicator plots opening range breakout levels across multiple timeframes, including five, fifteen, thirty, and sixty minutes, directly on the price chart. It also displays the session open and overnight high and low levels. The script calculates an openin

Indicator v6 BreakoutSessions & time
Updated 13 days ago · Custom licence GitHub repository of Nexural ORB

5000x Breakout Scanner

by jmragsdale
8 stars

This indicator marks momentum breakouts on the price chart. A signal appears only when the bar makes a new high over the lookback, volume is at least a chosen multiple of the 20-bar average, the percentage change from the prior close meets a minimum, the close

Indicator v5 BreakoutVolume
Updated 7 weeks ago · None stated GitHub repository of 5000x Breakout Scanner

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers