I came over this indicator combining CCI with RSI (futures.io) and it doenst plot anything.
Can somebody doublecheck the code?
Thanks
Can somebody doublecheck the code?
Thanks
Code:
######RSI_MTFs_CCI########
declare lower;
input length = 4;
input over_Bought = 50;#70
input over_Sold = 20;
input price = close;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
RSI.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RSI.DefineColor("OverBought", color.green);
RSI.DefineColor("Normal", color.pink);
RSI.DefineColor("OverSold", Color.RED);
#RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));
RSI.AssignValueColor(if RSI > over_Bought then RSI.Color("OverBought") else if RSI < over_Sold then RSI.Color("OverSold") else RSI.Color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
RSI.SetLineWeight (5);
#plot DL = 100;
#DL.HideBubble();
#DL.SetDefaultColor(Color.WHITE);
#DL.SetLineWeight(1);
###############5MIN##############################################
#input averageType = AverageType.WILDERS;
def NetChgAvg5 = MovingAverage(averageType, close(period = AggregationPeriod.FIVE_MIN) - close(period = AggregationPeriod.FIVE_MIN)[1], length);
def TotChgAvg5 = MovingAverage(averageType, AbsValue(close(period = AggregationPeriod.FIVE_MIN) - close(period = AggregationPeriod.FIVE_MIN)[1]), length);
def ChgRatio5 = if TotChgAvg5 != 0 then NetChgAvg5 / TotChgAvg5 else 0;
plot RSI5 = 50 * (ChgRatio + 1);
plot OverSold5 = over_Sold;
plot OverBought5 = over_Bought;
RSI5.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
RSI5.DefineColor("OverBought", GetColor(6));
RSI5.DefineColor("Normal", color.pink);#CreateColor(192, 192, 208));
RSI5.DefineColor("OverSold", Color.RED);
RSI5.AssignValueColor(if RSI5 > over_Bought then RSI5.Color("OverBought") else if RSI5 < over_Sold then RSI5.Color("OverSold") else RSI5.Color("Normal"));
RSI5.SetLineWeight (5);
###############################################
###########################10MIN###############
input length15 = 4;
input over_Bought15 = 70;
input over_Sold15 = 30;
input averageType15 = AverageType.WILDERS;
def NetChgAvg15 = MovingAverage(averageType15, close(period = AggregationPeriod.TEN_MIN) - close(period = AggregationPeriod.TEN_MIN)[1], length15);
def TotChgAvg15 = MovingAverage(averageType15, AbsValue(close(period = AggregationPeriod.TEN_MIN) - close(period = AggregationPeriod.TEN_MIN)[1]), length15);
def ChgRatio15 = if TotChgAvg15 != 0 then NetChgAvg15 / TotChgAvg15 else 0;
plot RSI15 = 50 * (ChgRatio15 + 1);
#plot OverSold15 = over_Sold15;
#plot OverBought15 = over_Bought15;
RSI15.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
RSI15.DefineColor("OverBought", Color.green);
DefineGlobalColor("FillColor", color.pink);#CreateColor(192, 192, 208));
RSI15.DefineColor("Normal", GlobalColor("FillColor" ));#GetColor(7));
RSI15.DefineColor("OverSold", Color.RED);
RSI15.AssignValueColor(if RSI15 > over_Bought15 then RSI15.Color("OverBought") else if RSI15 < over_Sold15 then RSI15.Color("OverSold") else RSI15.Color("Normal"));
#OverSold15.SetDefaultColor(GetColor(8));
#OverBought15.SetDefaultColor(GetColor(8));
RSI15.SetLineWeight (2);
###############################################
input length30 = 4;
input over_Bought30 = 70;
input over_Sold30 = 30;
input averageType30 = AverageType.WILDERS;
def NetChgAvg30 = MovingAverage(averageType30, close(period = AggregationPeriod.THIRTY_MIN) - close(period = AggregationPeriod.THIRTY_MIN)[1], length30);
def TotChgAvg30 = MovingAverage(averageType30, AbsValue(close(period = AggregationPeriod.THIRTY_MIN) - close(period = AggregationPeriod.THIRTY_MIN)[1]), length30);
def ChgRatio30 = if TotChgAvg30 != 0 then NetChgAvg30 / TotChgAvg30 else 0;
plot RSI30 = 50 * (ChgRatio30 + 1);
###plot OverSold30 = over_Sold30;
###plot OverBough30 = over_Bought30;
RSI30.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
RSI30. Hide ();
RSI30.DefineColor("OverBought", Color.green);
RSI30.DefineColor("Normal", color.pink);#GetColor(7));
RSI30.DefineColor("OverSold", Color.RED);
RSI30.AssignValueColor(if RSI30 > over_Bought30 then RSI30.Color("OverBought") else if RSI30 < over_Sold30 then RSI30.Color("OverSold") else RSI30.Color("Normal"));
###OverSold30.SetDefaultColor(GetColor(8));
###OverBough30.SetDefaultColor(GetColor(8));
RSI30.SetLineWeight (5);
##################################################
############ HOUR #############################
#input lengthh = 4;
#input over_Boughth = 70;
#input over_Soldh = 30;
#input averageTypeh = AverageType.WILDERS;
#input price = close;
#def NetChgAvgh = MovingAverage(averageType, price - price[1], length);
#def TotChgAvgh = MovingAverage(averageType, AbsValue(price - price[1]), length);
#def ChgRatioh = if TotChgAvgh != 0 then NetChgAvgh / TotChgAvgh else 0;
#plot RSIh = 50 * (ChgRatioh + 1);
#plot OverSoldh = over_Soldh;
#plot OverBoughh = over_Boughth;
#RSIh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#RSIh.DefineColor("OverBought", Color.GREEN);
#RSIh.DefineColor("Normal", GetColor(7));
#RSIh.DefineColor("OverSold", Color.RED);
#RSIh.AssignValueColor(if RSIh > over_Boughth then RSIh.Color("OverBought") else if RSIh < over_Soldh then RSIh.Color("OverSold") else RSIh.Color("Normal"));
###OverSold30.SetDefaultColor(GetColor(8));
###OverBough30.SetDefaultColor(GetColor(8));
#RSIh.SetLineWeight (5);
##################################################################
#######################CCI#######################################
input lengthCCI = 14;#14
input over_soldCCI = -100;
input over_boughtCCI = 100;
def priceCCI = close + low + high;
def linDev = LinDev(priceCCI, lengthCCI);
plot CCI = if linDev == 0 then 0 else (priceCCI - Average(priceCCI, lengthCCI)) / linDev / 0.015;
plot OverBoughtCCI = over_boughtCCI;
plot ZeroLine = -0;
plot OverSoldCCI = over_soldCCI;
plot UpSignal = if Crosses(CCI, ZeroLine, CrossingDirection.ABOVE) then ZeroLine else Double.NaN;
plot DownSignal = if Crosses(CCI, over_boughtCCI, CrossingDirection.BELOW) then ZeroLine else Double.NaN;
CCI.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
CCI.SetDefaultColor(GetColor(9));
CCI.DefineColor("OverBought",GetColor(6));
CCI.DefineColor("Normal", GetColor(7));
CCI.DefineColor("OverSold", Color.RED);
#CCI.AssignValueColor(if CCI > over_soldCCI then CCI.Color("OverBought") else if CCI < over_boughtCCI then CCI.Color("OverSold") else CCI.Color("Normal"));
CCI.AssignValueColor(if CCI > ZeroLine then CCI.Color("OverBought") else if CCI < ZeroLine then CCI.Color("OverSold") else CCI.Color("Normal"));
OverSoldCCI.SetDefaultColor(GetColor(8));
OverBoughtCCI.SetDefaultColor(GetColor(8));
CCI.SetLineWeight (1);
OverBoughtCCI.SetDefaultColor(GetColor(5));
ZeroLine.SetDefaultColor(GetColor(4));
OverSoldCCI.SetDefaultColor(GetColor(5));
###############################################################