Woodies CCI with ChopZone and Sidewinder indicator

4alphabsolute · study · 82 行 · 点赞 1,065 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=3
study(title="Woodies CCI with ChopZone and Sidewinder indicator")
 
//declaration of variables
source = close
colorTurquoise = #34dddd
colorDarkGreen = #006400
colorPaleGreen = #98fb98
colorLime = lime
colorDarkRed = #8B0000
colorRed = red
colorOrange = orange
colorLightOrange = #ffc04c
colorYellow = yellow
 
avg = hlc3
 
pi = atan(1) * 4
periods = 30
highestHigh = highest(periods)
lowestLow = lowest(periods)
range = 25 / (highestHigh - lowestLow) * lowestLow
 
//Chopzone indicator
 
ema34 = ema(source, 34)
x1_ema34 = 0
x2_ema34 = 1
y1_ema34 = 0
y2_ema34 = (ema34[1] - ema34) / avg * range
c_ema34 = sqrt((x2_ema34 - x1_ema34)*(x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34)*(y2_ema34 - y1_ema34))
emaAngle_1 = round(180 * acos((x2_ema34 - x1_ema34)/c_ema34) / pi)
emaAngle = iff(y2_ema34 > 0, - emaAngle_1, emaAngle_1)
 
chopZoneColor = emaAngle >= 5 ? colorTurquoise : emaAngle < 5 and emaAngle >= 3.57 ? colorDarkGreen : emaAngle < 3.57 and emaAngle >= 2.14 ? colorPaleGreen : emaAngle < 2.14 and emaAngle >= .71 ? colorLime : emaAngle <= -1 * 5 ? colorDarkRed : emaAngle > -1 * 5 and emaAngle <= -1 * 3.57 ? colorRed : emaAngle > -1 * 3.57 and emaAngle <= -1 * 2.14 ? colorOrange : emaAngle > -1 * 2.14 and emaAngle <= -1 * .71 ? colorLightOrange : colorYellow
 
// Woodies CCI indicator
 
cciTurboLength = input(title="CCI Turbo Length", type=integer, defval=6, minval=3, maxval=14)
cci14Length = input(title="CCI 14 Length", type=integer, defval=14, minval=7, maxval=20)
 
 
cciTurbo = cci(source, cciTurboLength)
cci14 = cci(source, cci14Length)
 
last5IsDown = cci14[5] < 0 and cci14[4] < 0 and cci14[3] < 0 and cci14[2] < 0 and cci14[1] < 0
last5IsUp = cci14[5] > 0 and cci14[4] > 0 and cci14[3] > 0 and cci14[2] > 0 and cci14[1] > 0
histogramColor = last5IsUp ? green : last5IsDown ? red : cci14 < 0 ? green : red
 
//LSMA indicator
length = input(title="Length", type=integer, defval=25)
offset = input(title="Offset", type=integer, defval=0)
 
src = input(open, title="Source")
 
lsma = linreg(src, length, offset)
lsmastd = stdev(abs(lsma[1] - lsma), length)
colorLine= abs(lsma - lsma[1]) < lsmastd ? white : lsma < lsma[1] ? red : green
//Sidewinder indicator
sum=change(lsma)+change(ema34)
//** radian angles
colorLineSW= abs(sum)> 1.7453 ? green : (abs(sum)>0.5235 and abs(sum)<1.0471) ? red : yellow
colorLineSW2= close > ema34 ? green : red 
//plots of CCIS
plot(cci14, title="CCI 14 area", color=histogramColor, style=histogram)
plot(cciTurbo, title="CCI Turbo", color=lime, style=line, linewidth=2)
plot(cci14, title="CCI 14", color=red, style=line, linewidth=2)
//plots of Chopzones
plot(100, title="plusle chop zone",color=chopZoneColor , style=line, linewidth=3, editable= false)
plot(-100, title="minus chop zone",color=chopZoneColor , style=line, linewidth=3, editable= false)
//plot of LSMA
plot(0, title="LSMA line",color=colorLine , style=line, linewidth=3, editable= false)
//plot of Sidewinder
plot(-200, title="-Sidewinder",color=colorLineSW , style=line, linewidth=3, editable= false)
plot(200, title="-Sidewinder",color=colorLineSW2 , style=line, linewidth=3, editable= false)
 
//hlines
hline(0, title="Zero Line", color=black, linestyle=solid)
hline(200, title="+Sidewinder line", color=black, linestyle=dotted)
hline(-200, title="-Sidewinder line", color=black, linestyle=dotted)
hline(100, title="+chop zone line", color=black, linestyle=dotted)
hline(-100, title="-chop zone line", color=black, linestyle=dotted)

← 返回列表