iCustom can't get data from custom indicator

 

hi everyone

i have a custom inidcator as you see here

it totaly works fine in live chart or tester but when i call it with iCustom it dosen't work right and always show the empty value 2147483647.0

the ea is very simple just calling  the dType value from custom indicator and if it was 1 a buy will be happen

#property indicator_separate_window
#property indicator_buffers 11


//#property indicator_plots 2
//#property indicator_level1 20
//#property indicator_level2 80
#property indicator_minimum 0
#property indicator_maximum 100
//#define arrowsDisplacement 0.0003
 string                DivergenceSettings_______________="DivergenceSettings_______________";
 string                RSI_settings                     = "RSI_settings---------------------------------------------------------";
 int                   RSI_period                       = 14;
 ENUM_APPLIED_PRICE    RSI_applied_price                = 0;
 bool                  RSI_Filter                       = false;
 int                   bearish_Level                    = 70;
 int                   bulish_Level                     = 30;
 int                   Signal_Bar                       = 2;
  string               Graphic_Setting                     ="Graphic_Setting ---------------------------------------------------------";
 color                 RSIColour                        = clrGoldenrod;
 ENUM_LINE_STYLE       RSIStyle                         = 0;
 int                   RSIWidth                         = 1;
 bool                  DisplayCard                =True;


//-------------------------------------------------------------------------------------------------------------
 string                LengthyDivergenceSettings_______________="LengthyDivergence_______________";
 bool                  Show_LongDivergence              = true;
 string                RSI_settings_Lengthy                     = "RSI_Settings_Lengthy ---------------------------------------------------------";
 int                   RSI_period_Lengthy                        = 14;
 ENUM_APPLIED_PRICE    RSI_applied_price_Lengthy                 = 0;
 bool                  RSI_Filter_Lengthy                        = false;
 int                   bearish_Level_Lengthy                     = 70;
 int                   bulish_Level_Lengthy                      = 30;
 int                   Signal_Bar_Lengthy                        = 2;
  string               Graphic_Setting_Lengthy                      ="Graphic_Setting_Lengthy  ---------------------------------------------------------";
 color                 RSIColour_Lengthy                         = clrGoldenrod;
 ENUM_LINE_STYLE       RSIStyle_Lengthy                          = 0;
 int                   RSIWidth_Lengthy                          = 1;
 bool                  DisplayCard_Lengthy                 =True;




//*************
/*
Abrrivation :
CC=Candle Confirmation
CCB=Candle Confirmation Breakout
CP=Candle Pattern
BUH=Bullsih Hammer
BUIH=Bullish Inverted Hammer
BEH=Bearish Hammer
BEIH=Bearish Inverted Hammer
BUE=Bullish Engualfing
BEE=Bearish Engualfing
PC=Piercing Candle
DCC=Dark Cloud Cover
BUS=bullish Sash
BES=Bearish Sash
MS=Morning Star
ES=Evening Star
*/
double rsi[],rsi_L[];
double dType[];
double dValid[];
double dUnvalid[];
double dCandlePatren[];
double dRSId[];
double dRSIdp[];
double Dopen[];
double Dclose[];
double Ddiff[];



//***********************************

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])

  {

//---
   int Counted_bars=prev_calculated;
   for(int i= rates_total-Counted_bars-1; i>=0; i--)
     {
      TRSI(i);

      Dir_BU_div_detec(i+2);  //Bulish


     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Dir_BU_div_detec(int shift) //checking for bullish divergence
  {

   if(IsdTgh(shift) == false)
      return;
   int cTgh = shift;
   int lTgh = GiLTgh(shift);
   if(rsi[cTgh] >= rsi[lTgh] && Close[cTgh]<=Close[lTgh] && Close[cTgh]<Open[cTgh] && Close[lTgh]<Open[lTgh] && BuC(lTgh,cTgh) && BuCr(lTgh,cTgh)&&((RSI_Filter&&rsi[cTgh]<bulish_Level)||RSI_Filter==0))
     {
      dType[cTgh]=1;

      dRSId[cTgh] = MathAbs(rsi[cTgh] - rsi[lTgh]);
      dRSIdp[cTgh] = MathAbs(Low[cTgh] - Low[lTgh]);



     }
  }

int sip;
//+------------------------------------------------------------------+
void TRSI(int x1)//cal rsi
  {
   sip = x1;
   rsi[x1] = iRSI(Symbol(),PERIOD_CURRENT,RSI_period,RSI_applied_price,x1);
   rsi_L[x1] = iRSI(_Symbol,PERIOD_CURRENT,RSI_period_Lengthy,RSI_applied_price_Lengthy,x1);
  }
//+------------------------------------------------------------------+
//-----------------------------------------------------------------+
bool IsdTgh(int shift) //check if rsi value is lowest around
  {
//
   if(rsi[shift] <= rsi[shift+1] && rsi[shift] <= rsi[shift-1])
      return(true);
   else
      return(false);
  }


//+------------------------------------------------------------------+
int GiLTgh(int shift)//checking if the rsi is a lower in the the around
  {
   for(int j = shift + 2; j <= shift+15; j++)
     {
      //
      if(rsi[j+1] >= rsi[j] && rsi[j] <= rsi[j-1])
         return(j);
     }
   return(-1);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
bool BuC(int st, int fn) // checking line dosen't corss any price or rsi  between
  {
   ObjectCreate(0,"cond"+fn,OBJ_TREND,0,Time[st],Close[st],Time[fn],Close[fn]);
   ObjectSetInteger(0,"cond"+fn,OBJPROP_RAY,false);
   ObjectSetInteger(0,"cond"+fn,OBJPROP_COLOR,clrBlue);
   for(int j=st-1; j>fn; j--)
     {
      if(Close[j]<ObjectGetValueByShift("cond"+fn,j))
        {
         ObjectDelete(0,"cond"+fn);
         return(false);
        }
     }
   ObjectDelete(0,"cond"+fn);
   return(true);
  }
//+---------------------------------- --------------------------------+

//+------------------------------------------------------------------+
bool BuCr(int st, int fn) // checking line dosen't corss any price or rsi  between
  {
   ObjectCreate(0,"cond"+fn+1,OBJ_TREND,1,Time[st],rsi[st],Time[fn],rsi[fn]);
   ObjectSetInteger(0,"cond"+fn+1,OBJPROP_RAY,false);
   ObjectSetInteger(0,"cond"+fn+1,OBJPROP_COLOR,clrBlue);
   for(int j=st-1; j>fn; j--)
     {
      if(rsi[j]<ObjectGetValueByShift("cond"+fn+1,j))
        {
         ObjectDelete(0,"cond"+fn+1);
         return(false);
        }
     }
   ObjectDelete(0,"cond"+fn+1);
   return(true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//find period for display card
//lastAlertTime_CCB=TimeCurrent();




   SetIndexBuffer(0, rsi);
   SetIndexBuffer(1, dType);

   SetIndexStyle(1,DRAW_NONE);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);

   SetIndexStyle(0,DRAW_LINE,RSIStyle,RSIWidth,RSIColour);
   SetIndexStyle(4,DRAW_LINE,RSIStyle_Lengthy,RSIWidth_Lengthy,RSIColour_Lengthy);


   SetIndexDrawBegin(0,RSI_period);
   SetIndexDrawBegin(5,RSI_period_Lengthy);
   IndicatorDigits(Digits() + 2);



   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//delete all object



  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

if anyone can help me i'm really appreciate it

 
Teh problem is probably your iCustom call.
 
lippmaje:
Teh problem is probably your iCustom call.

it's very simple call:

 double Div0=iCustom(NULL,0,"ABCD",0,2);

 
 double Div0=iCustom(NULL,0,"ABCD",1,2);
 
lippmaje:

yes the index 1 

but still doesn't work always show empty value

 

Check that "ABCD" matches your indicator. Reset and test _LastError after iCustom.

   for(int i= rates_total-Counted_bars-1; i>=0; i--)

This for-loop header looks strange. You will get only 1 calculation for the first tick of any new bar.

Reason: