-
Notifications
You must be signed in to change notification settings - Fork 2
/
4X EMA and volume strategy.pine
93 lines (86 loc) · 1.88 KB
/
4X EMA and volume strategy.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Script Name: 4X EMA and volume strategy
Author: SoftKill21
Description: This is a strategy made from multiple types of EMA and volume(EOM).
This is a long only strategy.
EMA 1 = 13
EMA 2 = 21
EMA 3 = 50
EMA 4 = 180
In this case we have 2 options for entry:
1.We check that are candles are in ascending order and EOM is above 0 - > long, descending and eom<0 -> exit long
2.We check if we have a crossover between the first ema with...
PineScript code:
Pine Script™ strategy
4X EMA and volume strategy
Copy code
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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SoftKill21
//@version=4
strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )
//ema x 4
ema1l=input(13)
ema2l=input(21)
ema3l=input(50)
ema4l=input(180)
ema1=ema(close,ema1l)
ema2=ema(close,ema2l)
ema3=ema(close,ema3l)
ema4=ema(close,ema4l)
long1 = close > ema1 and ema1 > ema2 and ema2> ema3 and ema3 > ema4
long2 = crossover(ema1,ema2) and crossover(ema1,ema3)
short1 = close < ema1 and ema1 < ema2 and ema2< ema3 and ema3 < ema4
short2= crossunder(ema1,ema2) and crossunder(ema1,ema3)
//eom
length = input(14, minval=1)
div = input(10000, title="Divisor", minval=1)
eom = sma(div * change(hl2) * (high - low) / volume, length)
option1=input(true)
option2=input(false)
if(option1)
strategy.entry("long",1,when=long1 and eom>0)
strategy.close("long",when=short1 and eom<0)
if(option2)
strategy.entry("long",1,when=long2 and eom>0)
strategy.close("long",when=short2 and eom<0)
Expand (40 lines)