-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathvwap_xo.txt
53 lines (46 loc) · 2.28 KB
/
vwap_xo.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
50
51
52
53
//@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: M9MBLWAC4puDxuqs4KfgSa216q1chLuaps
//contact: [email protected]
study("VWAP XO", shorttitle="VWAP XO", precision=0, overlay=false)
ma1len = input(3, "Price Period")
psource = input(false, title="Use VWMA?(Close)")
strend = input(true, title="Show MAs?")
trend1 = input(21, "Trend period 1")
trend2 = input(89, "Trend period 2")
smoothp = input(4, "Smooth factor", step=1, minval=0)
src = close
offset = 0.85
sigma = 6
hullma(_src, _length)=>
_hullma = wma((2 * wma(_src, _length / 2)) - wma(_src, _length), round(sqrt(_length)))
ma1 = psource ? vwma(close, ma1len) : src
vwapxo = ma1 - vwap(close)
mainline = smoothp > 0 ? hullma(vwapxo, smoothp) : vwapxo
sline0 = alma(vwapxo, 3, offset, sigma)
sline1 = alma(vwapxo, trend1, offset, sigma)
sline2 = alma(vwapxo, trend2, offset, sigma)
hist = mainline
//color codes
crimson = #DC143C
forestgreen = #228B22
darkorange = #FF8C00
xcolor = mainline >= 0 ? lime : crimson
//xcolor = mainline >= 0 ? #219932 : #CB2E0F
crossing_u = crossover(sline0, 0)
crossing_d = crossunder(sline0, 0)
isnegative = hist < 0
ispositive = hist >= 0
isstrong = change(hist,1) > 0
isweak = change(hist,1) <= 0
//histcolor = isnegative and isstrong ? maroon : isnegative and isweak ? crimson : ispositive and isstrong ? lime : forestgreen
//plot(hist, color=histcolor, style=histogram, linewidth=4, transp=0, editable=false, title="Histogram")
hline(0, 'Zero', linestyle=dashed, linewidth=1, color=#7B68EE, editable=false)
plot(strend ? sline2 : na, style = line, color=#E500BB , linewidth=2, transp=0, title="Long MA")
plot(strend ? sline1 : na, style = line, color=#1A9AB2 , linewidth=2, transp=0, title="Short MA")
plot(mainline, style=line, color=xcolor, linewidth=2, transp=0,title="Price trend")
plotshape(crossing_u, title="Above VWAP", style=shape.labelup, location=location.bottom, color=forestgreen, transp=0, size=size.tiny, editable=false)
plotshape(crossing_d, title="Below VWAP", style=shape.labeldown, location=location.top, color=crimson, transp=0, size=size.tiny, editable=false)