Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# 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
# 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);
declare upper;
input cciLength = 14;
input cciAvgLength = 9;
input over_sold = -100;
input over_bought = 100;
def CCI = CCI(length = cciLength);
def CCIAvg = Average(CCI, cciAvgLength);
def OverBought = over_bought;
def OverSold = over_sold;
plot UpSignal = CCI crosses above oversold;
plot DownSignal = CCI crosses below overbought;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
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...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?
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);
#
# TD Ameritrade IP Company, Inc. (c) 2017-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;
def ZeroLine = 0;
def condition1 = CCI crosses above over_sold;
def condition2 = CCI crosses below over_bought;
def condition3 = CCI crosses Zeroline;
AssignBackgroundColor(if condition1 then color.dark_green else if condition2 then color.dark_red else if condition3 then color.blue else color.gray);
In a lower study can the Up and Down Arrows always appear at the very top of the Window?UpSignal.SetDefaultColor(Color.GREEN); UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); DownSignal.SetDefaultColor(Color.RED); DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.