-
Notifications
You must be signed in to change notification settings - Fork 16
/
greeffer-bb-strategy-0.pine
27 lines (21 loc) · 1.43 KB
/
greeffer-bb-strategy-0.pine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Greeffer
// 04-11-2020: 5.7% profit in backtests trading BTCUSDTPERP on 1m time frame (no leverage)
strategy("Greeffer BB Strategy", "Greeffer", false, format=format.price, scale=scale.right, precision=2, pyramiding=11, default_qty_type=strategy.percent_of_equity, default_qty_value=11, initial_capital=100000, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.075, process_orders_on_close=true)
source = close
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
if (crossover(source, upper))
strategy.entry("sell", strategy.short, comment="sell", when = rsi(close, 14) > 70)
strategy.close("sell", when= rsi(close, 14) < 30, qty_percent = 100, comment = "close sell 50%")
if (crossunder(source, lower))
strategy.entry("buy", strategy.long, oca_name="BollingerBands", comment="buy", when = rsi(close, 14) > 30)
strategy.close("buy", when = rsi(close, 14) > 70, qty_percent = 100, comment = "close buy 50%")
//strategy.risk.max_drawdown(3, strategy.percent_of_equity) // set maximum drawdown to 50% of maximum equity
//strategy.close_all(when= , comment="close all")
plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)