I need someone to help me please with this indicator, before it worked well in all periods, now what happens is that the period of H4 only shows in the periods below this, someone could help?
Thanks regards Max
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Black
#property indicator_color2 Black
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_color5 Black
//----
extern int CCITimeFrame=240;
extern int CCIPeriod=5;
extern int TimeOffset=3;
//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[];
double P5Buffer[];
double P6Buffer[];
double P7Buffer[];
double P8Buffer[];
//----
double L200, L100, L0, Ln100, Ln200;
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, P1Buffer);
SetIndexBuffer(1, P2Buffer);
SetIndexBuffer(2, P3Buffer);
SetIndexBuffer(3, P4Buffer);
SetIndexBuffer(4, P5Buffer);
//----
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1);
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
//----
Comment(“CCI (”+CCIPeriod+")");
return(0);
}
//±-----------------------------------------------------------------+
//| Custor indicator deinitialization function |
//±-----------------------------------------------------------------+
int deinit()
{
ObjectDelete(“CCI200” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“txtCCI200” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“CCI100” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“txtCCI100” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“CCI0” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“txtCCI0” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“CCIn100” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“txtCCn100” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“CCIn200” + DoubleToStr(CCIPeriod, 0));
ObjectDelete(“txtCCIn200” + DoubleToStr(CCIPeriod, 0));
Comment("");
return(0);
}
//±-----------------------------------------------------------------+
//| Custom indicator iteration function |
//±-----------------------------------------------------------------+
int start()
{
int i, dayi, counted_bars = IndicatorCounted();
double CCI1, CCI2, c1, c2, dCCI, dc;
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars–;
int limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i–)
{
dayi = iBarShift(Symbol(), CCITimeFrame, Time[i],true);
if(dayi != -1)
{
CCI1 = iCCI(Symbol(), CCITimeFrame, CCIPeriod, PRICE_CLOSE, dayi + 1);
CCI2 = iCCI(Symbol(), CCITimeFrame, CCIPeriod, PRICE_CLOSE, dayi + 2);
c1 = iClose(Symbol(), CCITimeFrame, dayi + 1);
c2 = iClose(Symbol(), CCITimeFrame, dayi + 2);
dCCI = CCI1 - CCI2;
if(dCCI == 0)
CCI2 = iCCI(Symbol(), CCITimeFrame, CCIPeriod, PRICE_CLOSE, dayi + 3);
dCCI = CCI1 - CCI2;
if(dCCI == 0)
dCCI = CCI1;
dc = c1 - c2;
if(dc == 0)
c2 = iClose(Symbol(), CCITimeFrame, dayi + 3);
dc = c1 - c2;
if(dc == 0)
dc = c1;
datetime CCITime=Time[i]+Period()60TimeOffset;
//—
L200 = (((200 - CCI1)*dc) / dCCI) + c1;
P1Buffer[i] = L200;
SetPrice(“CCI200” + DoubleToStr(CCIPeriod, 0), CCITime,
L200, Blue);
SetText(“txtCCI200” + DoubleToStr(CCIPeriod, 0), “CCI 200”,
Time[i], L200, Blue);
//—
L100=(((100 - CCI1)*dc) / dCCI) + c1;
P2Buffer[i] = L100;
SetPrice(“CCI100” + DoubleToStr(CCIPeriod, 0), CCITime,
L100, Red);
SetText(“txtCCI100” + DoubleToStr(CCIPeriod, 0), “CCI 100”,
Time[i], L100, Red);
//----
L0 = (((0 - CCI1)*dc) / dCCI) + c1;
P3Buffer[i] = L0;
SetPrice(“CCI0” + DoubleToStr(CCIPeriod, 0), CCITime,
L0, Green);
SetText(“txtCCI0” + DoubleToStr(CCIPeriod, 0), “CCI 0”,
Time[i], L0, Green);
//----
Ln100 = (((-100 - CCI1)*dc) / dCCI) + c1;
P4Buffer[i] = Ln100;
SetPrice(“CCIn100” + DoubleToStr(CCIPeriod, 0), CCITime,
Ln100, Red);
SetText(“txtCCIn100” + DoubleToStr(CCIPeriod, 0), “CCI -100”,
Time[i], Ln100, Red);
//----
Ln200 = (((-200 - CCI1)*dc) / dCCI) + c1;
P5Buffer[i] = Ln200;
SetPrice(“CCIn200” + DoubleToStr(CCIPeriod, 0), CCITime,
Ln200, Green);
SetText(“txtCCIn200” + DoubleToStr(CCIPeriod, 0), “CCI -200”,
Time[i], Ln200, Green);
}
}
return(0);
}
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
void SetPrice(string name, datetime Tm, double Prc, color clr)
{
if(ObjectFind(name) == -1)
{
ObjectCreate(name, OBJ_ARROW, 0, Tm, Prc);
ObjectSet(name, OBJPROP_COLOR, clr);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}
else
{
ObjectSet(name, OBJPROP_TIME1, Tm);
ObjectSet(name, OBJPROP_PRICE1, Prc);
ObjectSet(name, OBJPROP_COLOR, clr);
ObjectSet(name, OBJPROP_WIDTH, 1);
ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}
}
//±-----------------------------------------------------------------+
//| |
//±-----------------------------------------------------------------+
void SetText(string name,string txt,datetime Tm,double Prc,color clr)
{
if(ObjectFind(name) == -1)
{
ObjectCreate(name, OBJ_TEXT, 0, Tm, Prc);
ObjectSetText(name, txt, 10, “Times New Roman”, clr);
ObjectSet(name, OBJPROP_CORNER, 2);
}
else
{
ObjectSet(name, OBJPROP_TIME1, Tm);
ObjectSet(name, OBJPROP_PRICE1, Prc);
ObjectSetText(name, txt, 10, “Times New Roman”, clr);
ObjectSet(name, OBJPROP_CORNER, 2);
}
}
//±-----------------------------------------------------------------+