-
Notifications
You must be signed in to change notification settings - Fork 16
/
bb-rsi-1m-3.pine
45 lines (39 loc) · 2.63 KB
/
bb-rsi-1m-3.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Greeffer
// 13.89% profit on 1m frame
//@version=4
//study("RSI/BB 1minute Study", shorttitle="BBW/RSI/1m", precision=5)
strategy("RSI/BB 1minute Study", "BBW/RSI/1m", false, format=format.inherit,
scale=scale.right, precision=5, pyramiding=20, default_qty_type=strategy.percent_of_equity,
default_qty_value=5, initial_capital=100000, currency=currency.USD,
commission_type=strategy.commission.percent, commission_value=0.075,
process_orders_on_close=true, calc_on_every_tick=false)
// R S I
source = close
sell = input(title="Sell", defval=70, minval=0, maxval=100)
buy = input(title="Buy", defval=30, minval=0, maxval=100)
length = input(title="Length", defval=14, minval=1, maxval=500)
myRsi = rsi(source, length)
plot(myRsi, title="myRsi", color=color.blue, linewidth=2, style=plot.style_line, transp=70)
hline(buy, title='buy', color=color.red, linestyle=hline.style_dotted, linewidth=1)
hline(sell, title='sell', color=color.red, linestyle=hline.style_dotted, linewidth=1)
// B o l i n g e r B a n d s
//bBands = bb(close, length, mult)
[middle, upper, lower] = bb(source, length, 2)
plot(middle, title="middle", color=color.red, display=display.none)
plot(upper, title="upper", color=color.green, display=display.none)
plot(lower, title="lower", color=color.green, display=display.none)
// B o l l i n g e r B a n d W i d t h
bbWidth = bbw(source, length, 2)
plot(bbWidth, title="bbWidth", color=color.orange, display=display.none)
// S t r a t e g i e s
x = strategy.position_avg_price + strategy.position_avg_price*0.1
if(crossunder(source, lower) and crossunder(myRsi, buy))
// strategy.entry(id, long, qty, limit, stop, oca_name, oca_type, comment, when)
strategy.entry("long0", strategy.long, qty=100, stop=x, oca_name="long0", oca_type=strategy.oca.reduce, when=strategy.position_size <= 0)
if(crossover(source, upper) and myRsi > 60)
//strategy.exit(id, from_entry, qty, qty_percent, profit, limit, loss, stop, trail_price, trail_points, trail_offset, oca_name, comment, when)
strategy.exit("longo", oca_name="long0", stop=x, trail_price=middle, trail_offset=2, when=strategy.position_size>0)
// A l e r t c o n d i t i o n s
//alertcondition(crossunder(myRsi, buy) and crossunder(close, lower), title='Buy', message='{"direction":"buy","ticker":"{{ticker}}","frame":"1minute","close":"{{close}}","time":"{{time}}"}')
//alertcondition(crossover(myRsi, sell) and crossover(close, upper), title='Sell', message='{"direction":"sell","ticker":"{{ticker}}","frame":"1minute","close":"{{close}}","time":"{{time}}"}')