-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsi-ema.pine
40 lines (30 loc) · 1.51 KB
/
rsi-ema.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
//@version=4
strategy("rsi+ema+st", overlay=true, default_qty_type=strategy.percent_of_equity,
default_qty_value=100, linktoseries=true, slippage=3, commission_type=strategy.commission.cash_per_order,
commission_value=30, initial_capital=10000)
rsiin = input(type=input.integer, defval=14)
fastmain = input(type=input.integer, defval=7)
slowmain = input(type=input.integer, defval=21)
rsi = rsi(close, rsiin)
fastma = ema(close, fastmain)
slowma = ema(close, slowmain)
mult = input(type=input.float, defval=3)
len = input(type=input.integer, defval=7)
[superTrend, dir] = supertrend(mult, len)
plot(series=fastma, title="fast", color=color.orange, linewidth=2)
plot(series=slowma, title="slow", color=color.black, linewidth=2)
plot(series=superTrend, title="st", color=dir<0 ? color.yellow : color.red, linewidth=2)
// plot(series=rsi, color=color.orange, linewidth=2)
// stopPer = input(5.0, title='Stop Loss %', type=input.float) / 100
if (year>2010)
if (rsi > 50 and fastma > slowma and dir < 0)
strategy.entry('long', long=true)
if (fastma < slowma)
strategy.close_all()
// if (strategy.position_size > 0)
// longStop = strategy.position_avg_price * (1 - stopPer)
// strategy.exit('long exit', 'long', stop=longStop, trail_price=strategy.position_avg_price+5)
if (year==2021 and month==2 and dayofmonth==11)
strategy.close_all()
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © udayadds