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
91 lines of Pine Script v4 from leobot/strategy.pine, published under CC0-1.0. Keep the author's credit and licence lines when you reuse it.
strategy.pine
// Greeffer's Long Strategy
// Tuned for the 5 minute time frame
// 40x leverage using 10% of equity per trade by default
// @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=400,
initial_capital=50,
commission_type=strategy.commission.percent,
commission_value=0.01,
margin_long=1./40*50,
margin_short=1./40*50
)
// I N P U T S
//sma = input(title="sma", type=input.integer, defval=250)
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.001)
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"
short = false
long = false
stopshort = close + stops
stoplong = close - stops
// to do:
//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
In long mode, it places limit buy orders when the low touches the lower Donchian band with volume exceeding a volume moving average multiple, and closes positions when price reaches the upper band. Inputs allow toggling between long and short modes, configuring channel periods, and setting volume multiplier thresholds. Drawn directly on the price chart.
Donchian Channel upper, lower, and middle line plots
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Long
bool
true
longOrShort
amount
float
0.001
amount
volume ma period
int
200
volumeMA
volume multiplyer
int
3
volMultiplyer
upper donchian channel period
int
1440
donchianupper
lower donchian channel period
int
1440
donchianlower
stops
float
500.00
stops
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 strategy plots Bollinger Bands on the price chart using an EMA or SMA basis and a matching standard-deviation calculation. It enters long when price crosses back above the lower band and short when price crosses back below the upper band. An optional Intr
This strategy runs on the price chart to identify trade entries using volume sequences, specifically tracking consecutive declining volume candles followed by a volume surge at lower price levels. It provides webhook execution support for Zignaly copy trading
This strategy computes the Cumulative Weighted Average Price (CWAP) using a selectable source price such as close, with user-defined reset periods including daily, weekly, monthly or session. Entry signals trigger when price reaches the CWAP line offset by a s
This overlay strategy requires sequential confluence before it enters. A hybrid detector blends selected oscillators, including RSI, CCI, MFI, Bollinger percent B and Keltner percent K, and treats extreme overbought or oversold readings as the market regime. V
This strategy detects Low Volume Node rejection and acceptance signals on the price chart using an SMA basis and ATR bands. It calculates LVN upper and lower bands as the basis plus or minus the width multiplier times ATR. Long entries trigger on rejection or
This strategy calculates a rolling volume-weighted average price and Chris Moody's Williams Vix Fix to detect market bottoms and oversold volatility spikes. It plots in a separate pane and colors chart bars based on filtered exhaustion criteria and price actio