declare lower; # not touching the CCI calc, but change default OB/OS to +45/-45 input length = 14; input over_sold = -45; input over_bought = 45; def price = close + low + high; def linDev = LinDev(price, length); ## i'll change the CCI Variable to a Rec .. not happy using plot with its implicit variable declaration..... rec CCIv = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015; ## back to original CCI study code plot CCI = CCIv; plot OverBought = over_bought; OverBought.HideTitle(); OverBought.HideBubble(); plot ZeroLine = 0; plot OverSold = over_sold; OverSold.HideTitle (); OverSold.HideBubble(); OverBought.SetDefaultColor(Color.GRAY); ZeroLine.SetDefaultColor(Color.YELLOW); OverSold.SetDefaultColor(Color.GRAY); # Change style to Histogram and color the bars - this code is from the MACD Histogram . use the Rec variable in the if statement. CCI.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); CCI.SetLineWeight(3); CCI.DefineColor("Positive and Up", Color.GREEN); CCI.DefineColor("Positive and Down", Color.DARK_GREEN); CCI.DefineColor("Negative and Down", Color.DARK_ORANGE); CCI.DefineColor("Negative and Up", Color.DARK_RED); CCI.AssignValueColor(if CCIv >= 0 then if CCIv > CCIv[1] then CCI.Color("Positive and Up") else CCI.Color("Positive and Down") else if CCIv < CCIv[1] then CCI.Color("Negative and Down") else CCI.Color("Negative and Up")); ## Counter section ... we flag a suqare for decreasing values def CCI_Flagpos = 300; def Count_up = CCIv > over_bought and CCIv < CCIv[1] ; def Count_Dn = CCIv < over_sold and CCIv > CCIv[1]; plot SignalFlag = if Count_up then CCI_Flagpos else if Count_Dn then -CCI_Flagpos else Double.NaN; SignalFlag.HideTitle(); SignalFlag.HideBubble(); SignalFlag.SetLineWeight (3); SignalFlag.SetPaintingStrategy (PaintingStrategy.SQUARES); SignalFlag.AssignValueColor (if Count_up then Color.DARK_GREEN else if Count_Dn then Color.DARK_RED else Color.WHITE);