-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathgreeffer-bb-strategy-4.pine
More file actions
38 lines (29 loc) · 1.67 KB
/
Copy pathgreeffer-bb-strategy-4.pine
File metadata and controls
38 lines (29 loc) · 1.67 KB
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
28
29
30
31
32
33
34
35
36
37
38
//@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
//
strategy("Greeffer BB Strategy", "Greeffer", false, format=format.price, scale=scale.right, precision=2, pyramiding=10, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=1000, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.075, process_orders_on_close=true)
source = close
length = input(20, minval=1)
rsiLength = input(14, minval=1)
mult = input(1.9, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
x = bbw(source, length, 2.1)
plot(bbw(source, length, 2.5), title="bb width", color=color.yellow)
if (x<0.01)
strategy.entry("buy", strategy.long, comment="buyx", when=rsi(close, rsiLength)<30)
//strategy.close("buy", when=rsi(close, 14)>80, comment = "close sell")
if (crossover(source, upper))
strategy.entry("sell", strategy.short, comment="sell", when=rsi(close, rsiLength)>80)
strategy.close("sell", when=crossunder(source, lower), comment = "close sell")
if (crossunder(source, lower))
strategy.entry("buy", strategy.long, comment="buy", when=rsi(close, rsiLength)>30)
strategy.close("buy", when=crossover(source, upper), comment = "close buy")
//plot(bbw(close, 20, 2), color=color.yellow)
//bb(series, length, mult)
//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)