OPEN-SOURCE SCRIPT

CCI Buy Signal

//version=5
indicator("CCI Buy Signal", overlay=true)

// Inputs for CCI
length = input.int(14, title="CCI Length")
src = input.source(close, title="Source")

// Calculate CCI
cci = ta.cci(src, length)
prev_cci = ta.valuewhen(bar_index > 0, cci[1], 0)

// Buy condition
buySignal = (cci < -100) and (cci > prev_cci)

// Plot CCI
plot(cci, color=color.blue, title="CCI")
hline(100, color=color.red, linestyle=hline.style_dotted, title="Upper Threshold")
hline(0, color=color.gray, linestyle=hline.style_dotted, title="Zero Line")
hline(-100, color=color.red, linestyle=hline.style_dotted, title="Lower Threshold")

// Plot Buy Signal as Arrow
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal Arrow")
Candlestick analysisChart patternsWoodies CCI

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer