-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAC-3.pine
46 lines (42 loc) · 1.46 KB
/
AC-3.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
//@version=5
indicator(title="AC-3")
a=#ffffff, b=#4b84ff, c=#787b86, d=#ff8f33, e=#00ff00, f=#ff0000, z=color.new(a,100)
C=close
i1=input(title='Relative Strength Indicator (RSI)',defval=true)
TC=ta.change(C)
SM(_p,_l)=>
_s=0.0
for i=0 to _l-1
_s+=_p[i]/_l
RM(_p)=>
_a=float(1)/14
_s=0.0
_s:=na(_s[1])?SM(_p,14):_a*_p+(1-_a)*nz(_s[1])
R=100-100/(1+RM(TC>=0?TC:0)/RM(TC<0?-TC:0))
plot(i1?R:na,color=a)
hline(i1?70:na)
hline(i1?30:na)
i2=input(title='Stochastic',defval=true)
L=ta.lowest(low,14)
K=(C-L)/(ta.highest(high,14)-L)*100
plot(i2?K:na)
plot(i2?SM(K,3):na,color=d)
hline(i2?80:na)
hline(i2?20:na)
i3=input(title='Divergence',defval=true)
pl=na(ta.pivotlow(R,5,5))?false:true
ph=na(ta.pivothigh(R,5,5))?false:true
_i(cond)=>
5<=ta.barssince(cond==true) and ta.barssince(cond==true)<=60
plot(pl?R[5]:na,offset=-5,color=low[5]<ta.valuewhen(pl,low[5],1) and R[5]>ta.valuewhen(pl,R[5],1) and _i(pl[1]) and pl and i3?e:z,linewidth=2)
plot(ph?R[5]:na,offset=-5,color=high[5]>ta.valuewhen(ph,high[5],1) and R[5]<ta.valuewhen(ph,R[5],1) and _i(ph[1]) and ph and i3?f:z,linewidth=2)
i4=input(title='Directional Movement Index',defval=true)
up=ta.change(high)
down=-ta.change(low)
trur=ta.rma(ta.tr,14)
plus=fixnan(100*RM(na(up)?na:up>down and up>0?up:0)/trur)
minus=fixnan(100*RM(na(down)?na:down>up and down>0?down:0)/trur)
sum=plus+minus
plot(i4?100*RM(math.abs(plus-minus)/(sum==0?1:sum)):na,color=#F50057)
plot(i4?plus:na,color=#2962FF)
plot(i4?minus:na,color=#FF6D00)