-
Notifications
You must be signed in to change notification settings - Fork 2
/
AM_ZLWMA Crossover_x.pine
95 lines (90 loc) · 2.33 KB
/
AM_ZLWMA Crossover_x.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
94
95
Script Name: AM_ZLWMA Crossover_x
Author: happyTacos
Description: Dear All,
Please find updated version of Zero lag WMA crossover. In addition to this added 20/50 EMA to get better results.
Settings:
ZLWMA = 8 identified by Blue line
Fast WMA = 21 identified by Red line
EMA Period 20/50
How to Trade:
Buy: Wait for positive crossover (Blue cross above Red) to happen trade can be taken there but to get better results post...
PineScript code:
Pine Script™ strategy
AM_ZLWMA Crossover_x
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
//The formula for a given N-Day period and for a given Data series is
//Lag=(Period-2)/3}
//EmaData=Data+(Data-Data(Lagdaysago)
//ZLEMA={EMA(EmaData,Period)
//The idea is do a regular exponential moving average (EMA) calculation
//but on a de-lagged data instead of doing it on the regular data.
//Data is de-lagged by removing the data from "lag" days ago thus removing (or attempting to) the cumulative effect of the moving average.
////////////////////////////////////////////////////////////////////////////////////////
//@version=2
strategy("AM_ZLWMA Crossover_x", overlay = true)
nPeriod = input(title="ZLWMA Period", type=integer, defval=8, minval=1)
xPrice = close
xLag = sqrt (nPeriod)
xWMAData = (xPrice + (xPrice - xPrice[xLag]))
xZLWMA = wma(xWMAData, nPeriod)
wmalength=input(21)
emalength1=input(20)
emalength2=input(50)
src=close
ema1 = ema(src, emalength1)
ema2 = ema(src, emalength2)
short = wma(src, wmalength)
long = xZLWMA
co = crossover(long, short)
cu = crossunder(long, short)
if (not na(xLag))
if (co)
strategy.entry("Long", strategy.long, comment="buy")
if (cu)
strategy.entry("Short", strategy.short, comment="sell")
plot(cross(short, long) ? short : na, style = cross, linewidth = 3)
col = long > short ? green : long < short ? red : blue
p1 = plot(short, title="short", style=linebr, linewidth=2, color=red)
p2 = plot(long, title="Long", style=linebr, linewidth=2, color=blue)
p3 = plot(ema1, title="EMA20", style=linebr, linewidth=3, color=green)
p4 = plot(ema2, title="EMA50", style=linebr, linewidth=3, color=yellow)
Expand (39 lines)