
Python
//@version=3
study("DCCフィボナッチ", overlay=true)
//DCCF
len=input(37, "DCC期間")
h3=highest(high,len)
l3=lowest(low,len)
len2=h3-l3
h2=h3-len2*0.236
h1=h3-len2*0.382
l1=h3-len2*0.618
l2=h3-len2*0.764
basis= avg(l3, h3)
//ENTRY&ALERT
LONG = cross(high,h3)
SHORT = cross(low,l3)
switch = 0
setA = 0
setB = 0
if (LONG and (switch[1] == 0))
switch := 1
setA := 1
setB := 0
else
if (SHORT and (switch[1] == 1))
switch := 0
setA := 0
setB := 1
else
switch := nz(switch[1],0)
setA := 0
setB := 0
alertcondition(setA, title = "HIGHT", message = "HIGHT")
alertcondition(setB, title = "LOW", message = "LOW")
//COLOR
fill(plot(h3, title="+3σ"), plot(l3, title="-3σ"), color = aqua)
fill(plot(h2, title="+2σ"), plot(l2, title="-2σ"), color = aqua)
fill(plot(h1, title="+1σ"), plot(l1, title="-1σ"), color = aqua)
plot(basis,color=orange,style=cross)
plotshape(setA,title="HIGHT",style=shape.triangleup,text="HI",color=blue,textcolor=blue,location=location.belowbar)
plotshape(setB,title="LOW",style=shape.triangledown,text="LO",color=red,textcolor=red,location=location.abovebar)