Indicator · Pine Script v4 · On the chart

Greeffer's Long Study

by modster

Greeffer's Long Study calculates Donchian Channels alongside a volume moving average filter to generate trade signals.

View on GitHub

GitHub stars3on the repository
Pine versionv4older, still runs
Lines of code88
Settings7inputs
LicenceCC0-1.0
Last update4 years ago16 Mar 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

88 lines of Pine Script v4 from leobot/study.pine, published under CC0-1.0. Keep the author's credit and licence lines when you reuse it.

study.pine
// Greeffer's Long Strategy
// @version=4
// @Greeffer

// S T U D Y
study(shorttitle="Long Study", title="Greeffer's Long Study", overlay=true)

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

// I N P U T S
longOrShort = input(title="Long", type=input.bool, defval=true, tooltip="Uncheck to Short")
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)
stops = input(title="stops", type=input.float, defval=500.00, step=0.01)

// V A R S
symbol = "BTCUSDT" //symbol = "ETHUSDT"
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 :
// L o n g
if long==true and longOrShort==true
    alert(message='{"side":"limitBuy","limit":"'+tostring(lower)+'","stopPrice":"'+tostring(stoplong)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    //strategy.order("long", long=true, limit=lower, oca_name="order", stop=stoplong, comment="long", when=long)

if short==true and longOrShort==true
    alert(message='{"side":"closeLong","stopPrice":"'+tostring(upper[3])+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    //strategy.close("long", comment="close-long", qty_percent=100, when=short)

// S h o r t
if short==true and longOrShort==false
    alert(message='{"side":"limitSell","limit":"'+tostring(upper)+'","stopPrice":"'+tostring(stopshort)+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    // strategy.order("short", long=false, limit=upper, oca_name="order", stop=stopshort, comment="short", when=short)

if long==true and longOrShort==false
    alert(message='{"side":"closeShort","stopPrice":"'+tostring(lower[3])+'","symbol":"'+symbol+'","close":"'+tostring(close)+'","amount":"'+tostring(amount)+'"}', freq=alert.freq_once_per_bar_close)
    //strategy.close("short", comment="close-short", qty_percent=100, when=long)

Overview

When price touches the lower or upper channel boundaries combined with volume exceeding a custom moving average multiplier, the indicator triggers entry or exit conditions. It plots the upper, lower, and middle Donchian Channel lines on the price chart. Designed for automated trading integrations, it generates JSON-formatted alert payloads on bar close for external order execution on platforms like Binance.

Details

Published by

modster on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Trend, Volatility & bands, Volume, Breakout

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

KLSE VCP Stage v2

by kevinesk
1 stars

This indicator classifies market structure into volatility contraction pattern (VCP) stages on the main price chart. It evaluates a Mark Minervini Trend Template score alongside Bollinger Band width percentiles and volume metrics to determine stages such as Co

Indicator v5 TrendVolatility & bands
Updated 4 months ago · None stated GitHub repository of KLSE VCP Stage v2

This indicator evaluates and scores trade signal quality using a four-layer filtering process drawn directly on the main chart. It evaluates volume spikes against a moving average, higher-timeframe EMA trend alignment, price breaches beyond ATR volatility band

Indicator v6 Volatility & bandsVolume Repaints
Updated 2 months ago · None stated GitHub repository of TeleNexus Fakeout Signal Quality

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope
92 stars

This indicator plots a volume-weighted average price of the typical price on the chart and colors that line by ADX strength. It draws a standard-deviation envelope around VWAP and tints the fill green when plus DI leads and red when minus DI leads. Triangle ma

Indicator v5 TrendOscillators & momentum
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev VWAP x ADX Explosion

This overlay indicator marks Wyckoff-style buying and selling climaxes on the price chart. It filters trend with an exponential moving average and a higher-timeframe EMA, then flags accumulation or distribution when price and ATR sit relative to their swing av

Indicator v6 TrendVolatility & bands
Updated 1 year ago · MIT GitHub repository of Ultimate Wyckoff Indicator V3 (Refined)

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