Johnman

CCI Crossover Alert

This very simple indicator will give you a blue background where the CCI crossed from below -100 to above -100, and a red background where it crossed from above 100 to below 100.
Remove from Favorite Scripts Add to Favorite Scripts
study("CCI Crossover Alert", overlay=true)
length=input(20, "Length", integer)

current = cci(close[0], length)
previous = cci(close[1], length)

bgcolor(current < 100 and previous > 100 ? red : na)
bgcolor(current > -100 and previous < -100 ? blue : na)

//plot(100, style=area, transp=95, color=blue)
//plot(-100, style=area, transp=95, color=blue)
//plot(cci(close, length))
Can you set an alert for this indicator to email
Reply
squattter PRO blackmagic30
that's way too complicated for what you want to do.

Just create a standard alert on a default cci indicator. crossing down value 100, on bar close, and second alert will be crossing up -100
Reply
im trying to add alert to this CCI template i got form the website. i am getting errors. any help. i watn a alert every time it crosses the CCI. below or above the 100 or - 100

study("CCI Crossover Alert_V4", overlay=true)
length=input(20, "Length", integer)

current = cci(close, length)
previous = cci(close, length)

bgcolor(current < 100 and previous > 100 ? red : na)
bgcolor(current > -100 and previous < -100 ? blue : na)

alert1= bgcolor(current < 100 and previous > 100 ? 1 : 0
alert2= bgcolor(current > -100 and previous < -100 ? 1 : 0

//plot(100, style=area, transp=95, color=blue)
//plot(-100, style=area, transp=95, color=blue)
//plot(cci(close, length))

plot(alert1, title="bgcolor alert", style=line, linewidth=1, color=yellow)
plot(alert2, title="bgcolor alert", style=line, linewidth=1, color=yellow)
Reply
hey thank you for posting this indicator, really helpful for me to learn coding and this is very simple yet useful! :) cheers!
Reply
Thank you!

One question: It seems to not fit with the same data given by the TradingView build-in CCI indicator - when crossing from below -100 to above -100. The built-in commodity channel indicator shows those crossings very noticeable earlier than your version of the CCI. Please compare them yourself.
Reply
Johnman ChartArt
Thanks for your comment. I don't quite understand what you mean though. As you can see, all I do is check if the built-in CCI is now above -100 and last period was below -100 (meaning it won't get triggered if it's exactly at -100).

Perhaps the problem is the painted background seems to come late because until the current candle isn't closed you can't be sure it has indeed crossed the threshold? I hope I'm explaining clearly. If I'm misunderstanding the problem please give me more details.
Reply
ChartArt Johnman
Yes, maybe the candle close is the problem.

Here is an example. I used your chart and switched to 5-minute (where I trade):

snapshot


Your CCI indicator signals are always lagging behind the actual crossings, although you are using the build-in version.
Reply
Johnman ChartArt
Yes, I think the problem is the signal is not given until the second candle (the one where the crossing happens) is closed. This means the signal is given on the opening of the third candle (first candle closes below, second candle closes above, third candle opens and signal appears). That is intentional because the second candle could reverse and close below, thus the signal not being confirmed.

Maybe you can alleviate this by modifying the code so it uses opening prices instead of closing prices, but that will also mean more false signals.

I'm a fundamental trader anyway, I only did this so I could learn a bit about programming indicators in TradingView so I really can't guarantee this usefulness of this. :P
Reply
ChartArt Johnman
I tried it before. When I changed:

current = cci(close, length)
previous = cci(close, length)

to

current = cci(open, length)
previous = cci(open, length)

The colored signal comes even one bar later than with the "close" setting. Don't ask me why :)
Reply
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
ประเทศไทย
Việt Nam
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Priority Support Contact Support Ideas Published Followers Following Private Messages Chat Sign Out