forked from foorbar/tradingview
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathppo death or golden cross
41 lines (33 loc) · 1.81 KB
/
ppo death or golden cross
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
//@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="PPO Death/Golden Cross", precision=1)
use250 = input(false, type=bool, title="Use 50vs250 SMA?(50vs200)")
showhist = input(false, type=bool, title="Show Histogram?")
showxo = input(false, type=bool, title="Show crossings?")
offset = 0.9
sigma = 6
price = close
short = sma(price, 50)
long = use250 ? sma(price, 250) : sma(price, 200)
osc_line = short - long
osc = 100 * (short - long) / long
osc_hist = osc - 0
forestgreen = #228B22
crimson = #DC143C
darkorange = #FF8C00
belowsignal = osc <= 10
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 : osc <= 10 ? orange : forestgreen
crossing_u = crossover(osc, 0)
crossing_d = crossunder(osc, 0)
plot(showhist ? osc_hist : na, color=ppocolorh, style=histogram, linewidth=4, transp=0, editable=true, title="Histogram", trackprice=true)
hline(0, 'Zero', linestyle=dashed, linewidth=1, color=#7B68EE, editable=false)
plot(osc, color=osc_color, linewidth=2, transp=0, style=line, editable=true, title="PPO")
plotshape(showxo ? crossing_u : na, title="Dot mark Up", style=shape.arrowup, location=location.top, color=forestgreen, transp=0, size=size.small, editable=false)
plotshape(showxo ? crossing_d : na, title="Dot mark Down", style=shape.arrowdown, location=location.bottom, color=crimson, transp=0, size=size.small, editable=false)