forked from rodrigo-brito/tradingview-strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_9_2.pine
53 lines (45 loc) · 1.23 KB
/
setup_9_2.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
46
47
48
49
50
51
52
53
//@version=4
strategy("Setup 9.2 - Larry Willians", overlay=true)
ema8 = ema(close, input(8))
ema9 = ema(close, input(9))
ema13 = sma(close, input(13))
ema54 = sma(close, input(54))
ema200 = sma(close, input(200))
sma20 = sma(close, input(20))
plot(ema9, color=color.red)
plot(sma20)
var INF = 9999999.9
var position = false
var active = false
var buy_price = INF
var stop_price = 0.0
if (ema9[0] < ema9[1] and active)
buy_price := INF
stop_price := 0.0
active := false
position := false
if (not position and close < low[1] and ema9[0] > ema9[1])
buy_price := high[0]
stop_price := low[0]
active := true
if (position and low < stop_price)
strategy.close("long", comment="stop")
buy_price := INF
stop_price := 0.0
active := false
position := false
if (position and close < sma20)
strategy.close("long", comment="sma sell")
buy_price := INF
stop_price := 0.0
active := false
position := false
if (active and high > buy_price and ema9 > sma20)
strategy.entry("long", strategy.long)
stop_price := min(low[0], stop_price)
position := true
active := false
else
if(active)
buy_price := min(high[0], buy_price)
stop_price := min(low[0], stop_price)