forked from foorbar/tradingview
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpp-vwma.txt
49 lines (42 loc) · 2.21 KB
/
pp-vwma.txt
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
//@version=3
//The files in this repository are created by me and provided under the MIT License
//located at https://github.com/yield65/tradingview/blob/master/LICENSE
//If you find them useful please consider making a donation, thank you.
//Bitcoin: 3F636VrPCdnbfrdP5kS4C6fHWVBffXNKCu
//Litecoin: 33932ckE7i3oAQZxxSgLcvmbn8RAgTc2tk
//ETH: 0x53A43EF9E56908A9c868FBf2f1b9DE7B3486FDAF
//contact: [email protected]
study(title="PP-VWMA", precision=0)
shortlen = input(5, minval=1, title="Short Lenght")
longlen = input(21, minval=1, title="Long Lenght")
showhist = input(false, type=bool, title="Show Histogram?")
showxo = input(false, title="Show crossings?")
price = close
offsets = 0.85
sigmas = 6
short = vwma(price, shortlen)
long = vwma(price, longlen)
osc_line = 100 * (short - long) / long
ma0 = alma(osc_line,3, offsets, sigmas)
ma1 = alma(osc_line,5, offsets, sigmas)
ma2 = alma(osc_line,8, offsets, sigmas)
ma3 = alma(osc_line,13, offsets, sigmas)
ma4 = alma(osc_line,21, offsets, sigmas)
ma5 = alma(osc_line,34, offsets, sigmas)
ma6 = alma(osc_line,55, offsets, sigmas)
signal = (ma0+ma1+ma2+ma3+ma4+ma5+ma6)/7
osc_hist = osc_line - signal
forestgreen = #228B22
crimson = #DC143C
darkorange = #FF8C00
belowsignal = osc_line <= signal
ppocolorh = belowsignal and osc_hist >= osc_hist[1] ? maroon : belowsignal and osc_hist < osc_hist[1] ? crimson : osc_hist < osc_hist[1] ? forestgreen : lime
osc_color = belowsignal ? crimson : forestgreen
crossing_u = crossover(osc_line, signal)
crossing_d = crossunder(osc_line, signal)
plot(showhist ? osc_hist : na, color=ppocolorh, style=histogram, linewidth=4, transp=0, editable=false, title="Histogram")
hline(0, 'Zero', linestyle=dashed, linewidth=1, color=#7B68EE, editable=false)
plot(osc_line, color=osc_color, linewidth=2, transp=0, style=line, editable=true, title="PP-VWMA")
plot(signal, linewidth=2, transp=0, style=line, editable=true, color=darkorange, title="Signal")
plotshape(showxo ? crossing_u : na, title="Dot mark Up", style=shape.arrowup, location=location.top, color=forestgreen, transp=0, size=size.tiny, editable=false)
plotshape(showxo ? crossing_d : na, title="Dot mark Down", style=shape.arrowdown, location=location.bottom, color=crimson, transp=0, size=size.tiny, editable=false)