Plot up and down arrows for CCI indicator?

J

jimmy rr

New member
i have been trying to plot cci studay on the lower plot with green dot when it crosses above zero line and red when it crosses down through the 100 i would also like to be able to change the length of cci and be able to put it in a watch list . thank for any help.
 
T

tomsk

Well-known member
VIP
@jimmy rr Taking a look at your request, it seems that the signals might be visually more apparent is arrows were used, so here is a study with GREEN arrows when CCI crosses above zero line and RED arrows when CCI crosses below the 100 line. The length of the CCI can be changed via the user interface so nothing to do there. The watchlist can be done quite easily as well - you've got to be real precise about what you'd like to see on the watchlist. Provide as much details as possible so there won't be any misinterpretation.

Here is your completed CCI study. I have also added labels and alerts to that chart study

Code:
# CCI Buy Sell Signals
# tomsk
# 1.12.2020

declare lower;

input length = 14;
input over_sold = -100;
input over_bought = 100;
input showBreakoutSignals = no;

def price = close + low + high;
def linDev = lindev(price, length);
plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
plot OverBought = over_bought;
plot ZeroLine = 0;
plot OverSold = over_sold;
plot UpSignal = if CCI crosses above 0 then 0 else Double.Nan;
plot DownSignal = if CCI crosses below 100 then 100 else Double.Nan;

CCI.setDefaultColor(GetColor(9));
OverBought.setDefaultColor(GetColor(5));
ZeroLine.setDefaultColor(GetColor(5));
OverSold.setDefaultColor(GetColor(5));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(5);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.SetLineWeight(5);

Alert(UpSignal, "CCI crosses above 0", Alert.BAR, Sound.Ring);
Alert(DownSignal, "CCI crosses below 100", Alert.BAR, Sound.Bell);
AddLabel(UpSignal, "CCI crosses above 0", Color.GREEN);
AddLabel(DownSignal, "CCI crosses below 100", Color.RED);
# End CCI Buy Sell Signals
 
horserider

horserider

Well-known member
VIP
Code:
# ToS CCI with downsignla changed to cross below 100 the overbought line.
# Horserider 1/12/2020 on request from jimmyrr

declare lower;

input length = 14;
input over_sold = -100;
input over_bought = 100;
input showBreakoutSignals = no;

def price = close + low + high;
def linDev = lindev(price, length);
plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
plot OverBought = over_bought;
plot ZeroLine = 0;
plot OverSold = over_sold;
plot UpSignal = if CCI crosses above ZeroLine then ZeroLine else Double.Nan;
plot DownSignal = if CCI crosses below  OverBought then  OverBought else Double.Nan;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

CCI.setDefaultColor(GetColor(9));
OverBought.setDefaultColor(GetColor(5));
ZeroLine.setDefaultColor(GetColor(5));
OverSold.setDefaultColor(GetColor(5));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
 
B

brdavis98

New member
2019 Donor
This is probably best for @BenTen but anyone would be my hero.

I've scanned through this site and found multiple threads for CCI. But I can't find (or I'm overlooking it) this... Is there a way to add a basic alert in the generic TOS-built CCI study whenever the arrows are triggered up or down as they cross the 0 line?
 
BenTen

BenTen

Administrative
Staff
VIP
Add this to the end of your script:

Code:
# Alerts
Alert(UpSignal, " ", Alert.Bar, Sound.Chimes);
Alert(DownSignal, " ", Alert.Bar, Sound.Bell);
 
S

sparhawk

New member
Hey guys, I used to do some simple coding in MT4, but I'm new to TOS. This should be very simple, but can someone tell me how to change the arrows so they plot on the chart instead of in the indicator window? Much appreciated!
 
B

brdavis98

New member
2019 Donor
Hey, this would be a nifty add, if anyone has any ideas.
 
rad14733

rad14733

Active member
VIP
Simply drag the lower study up to the upper study section and, optionally, turn off the all of the plots except UpSignal and DownSignal... Or maybe you'll like the entire study overlaying the chart action like I do with the RSI...

Edited to add: I see now that the arrows plot where the zero line would be so this may not be the best option...
 
Last edited:
S

sparhawk

New member
I appreciate the suggestion @rad14733, but the arrows do get a tad funky on the chart. Anyone else have suggestion on how to properly get the arrows to display on the main chart?
 
rad14733

rad14733

Active member
VIP
I appreciate the suggestion @rad14733, but the arrows do get a tad funky on the chart. Anyone else have suggestion on how to properly get the arrows to display on the main chart?
If I get a chance, I'll see if I can write a script that references the study above and places arrows at the high or low as an upper study...
 
horserider

horserider

Well-known member
VIP
@sparhawk
Code:
input length = 20;
input showBreakoutSignals = yes;

def price = close + low + high;
def linDev = lindev(price, length);
def CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;

input OverBought = 1;
input OverSold = -1;

plot UpSignal = if CCI crosses above OverBought then OverBought else Double.Nan;
plot DownSignal = if CCI crosses below OverSold then OverSold else Double.Nan;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

UpSignal.SetDefaultColor(Color.GREEN);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.RED);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
S

sparhawk

New member
@horserider thank you so much! This is perfect for what I need. I really appreciate it.

One final question. Is it possible to make a CCI scanner? Similar to a MA crossover scan it would catch when a crossover occurs, but the CCI scan should catch a crossover of the zero line in either direction. Ideally you would be able to change the time frame.

If anyone can make that scan I'll pass along my simple strategy for catching great swing trades using CCI. I confirm entries using a few MA's and looking at past S/R levels.
 
Last edited by a moderator:
horserider

horserider

Well-known member
VIP
@sparhawk Not a scanner expert. Maybe

CCI()."CCI" crosses CCI()."ZeroLine" within 2 bars

Give crosses both directions. If do not want "within 2 bars" just delete that part.
 

Similar threads

Top