-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathKlinger [Yield]
111 lines (91 loc) · 3.95 KB
/
Klinger [Yield]
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//@version=3
//Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)
//This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
//To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
//
//If you find this work useful please consider making a donation, thank you.
//
//Bitcoin: 3F636VrPCdnbfrdP5kS4C6fHWVBffXNKCu
//Litecoin: 33932ckE7i3oAQZxxSgLcvmbn8RAgTc2tk
//ETH: 0x53A43EF9E56908A9c868FBf2f1b9DE7B3486FDAF
//contact: [email protected]
//created by Yield
study(title="Klinger [Yield]", shorttitle="Klinger [Yield]", precision=0)
showxo = input(false, type=bool, title="Show 0 crossings?")
showsignal = input(false, type=bool, title="Show signal?")
usezero = input(true, type=bool, title="Zero as pivot?")
useavg = input(true, type=bool, title="Signal Ribbon?")
paintbg = input(true, type=bool, title="Paint background?")
//Short lenght period
fastp = 33
offset = input(0.85, step=0.05, minval=0.1, maxval=1)
sigma = input(9, step=1, minval=1)
offsets = input(0.45, step=0.05, minval=0.1, maxval=1)
sigmas = input(9, step=1, minval=1)
t = tickerid(syminfo.prefix, ticker)
realO = security(t, period, open)
realH = security(t, period, high)
realL = security(t, period, low)
realC = security(t, period, close)
//KAMA
kama(_src)=>
erp = 10
fastMA = 2
slowMA = 30
change = abs(_src - _src[erp])
volatility = sum(abs(_src - _src[1]), erp)
er = change/volatility
fastAlpha = (2/(fastMA+1))
slowAlpha = (2/(slowMA+1))
sc = pow( er * (fastAlpha - slowAlpha ) + slowAlpha, 2)
kama = 0.0
kama := nz(kama[1]) + sc * (realC - nz(kama[1]))
//KAMA
sv = change(realC,1) > 0 ? volume : -volume
fast = alma(sv, fastp, offset, sigma)
slow = kama(sv)
kvo_line = fast - slow
ma0 = alma(kvo_line,3, offsets, sigmas)
ma1 = alma(kvo_line,5, offsets, sigmas)
ma2 = alma(kvo_line,8, offsets, sigmas)
ma3 = alma(kvo_line,13, offsets, sigmas)
ma4 = alma(kvo_line,21, offsets, sigmas)
ma5 = alma(kvo_line,34, offsets, sigmas)
ma6 = alma(kvo_line,55, offsets, sigmas)
ma_signal = (ma0+ma1+ma2+ma3+ma4+ma5+ma6)/7
signal = ma_signal
hist = kvo_line
baseline = 0
//histogram colors red
color1 = #800000 // maroon (weak hist)
color2 = #CD5C5C // IndianRed (strong hist)
//histogram colors green
color3 = #006400 //DarkGreen
color4 = #3CB371 //MediumSeaGreen
//klinger colors
color5 = #FF0000 //red1
color6 = #00FF00 //lime
abovezero = crossover(kvo_line, 0)
belowzero = crossunder(kvo_line, 0)
isnegative = kvo_line < 0
ispositive = kvo_line >= 0
isstrong = change(kvo_line,1) > 0
isweak = change(kvo_line,1) <= 0
histstrong = change(hist,1) > 0
histweak = change(hist,1) <= 0
histnegative = hist < 0
histpositive = hist >= 0
kvo_color = histnegative and histstrong ? color1 : histnegative and histweak ? color2 : histpositive and histstrong ? color4 : color3
kvo = kvo_line
xcolor = kvo_line < 0 ? color5 : color6
signal_color = #FF8C00
crossing_u = crossover(kvo_line, 0)
crossing_d = crossunder(kvo_line, 0)
hline(0, 'Zero', linestyle=dashed, linewidth=1, color=#7B68EE, editable=false)
kvop=plot(kvo, color = kvo_color, transp=0, linewidth=2, title="Klinger Volume", editable=true, style=columns)
sigp=plot(showsignal ? signal : na, color = signal_color, transp=0, linewidth=2, title="Signal", editable=true, style=line)
bgcolor(paintbg and (ispositive and kvo < signal) ? orange : na, transp=80, title="Weak zone")
bgcolor(paintbg and (isnegative and kvo > signal) ? blue : na, transp=80, title="Pump zone")
plotshape(showxo ? crossing_u : na, title="Dot mark Up", style=shape.arrowup, location=location.top, color=color6, transp=0, size=size.tiny, editable=false)
plotshape(showxo ? crossing_d : na, title="Dot mark Down", style=shape.arrowdown, location=location.bottom, color=color5, transp=0, size=size.tiny, editable=false)
alertcondition(crossunder(kvo_line,0), title='KVO down', message='KVO down')