Indicators embedding in Expert Advisors (iCustom alternative)

 
Hello,

i learned the example but sry i don`t understand it :(

what i make wrong... can anyone say it me
i would calculate with the value of KFull[i] from the indicator in the start

#property copyright "AF"
#property link      ""
 
//---- input parameters
 
extern string note1 = "Chart Time Frame";
extern string note2 = "0=current time frame";
extern string note3 = "1=M1, 5=M5, 15=M15, 30=M30";
extern string note4 = "60=H1, 240=H4, 1440=D1";
extern string note5 = "10080=W1, 43200=MN1";
extern int    timeFrame    = 0;        // {1=M1, 5=M5, 15=M15, ..., 1440=D1, 10080=W1, 43200=MN1}
extern string note6 = "Stochastic settings";
extern int       KPeriod       =   14;
extern int       DPeriod       =   3;
extern int       Slowing       =   3;
extern string note7 = "0=sma, 1=ema, 2=smma, 3=lwma";
extern int       MAMethod      =   0;
extern string note8 = "0=high/low, 1=close/close";
extern int       PriceField    =   0;
extern string note9 = "overbought level";
extern double       overBought    =  80;
extern string note10 = "oversold level";
extern double       overSold      =  20;
extern bool      showBars      = false;
extern bool      showArrows    = false;
extern bool      alertsOn      = false;
extern bool      alertsMessage = true;
extern bool      alertsSound   = false;
extern bool      alertsEmail   = false;
 
 
//---- buffers
double   KFull[];
double   DFull[];
double   Upper[];
double   Lower[];
double   Uptrend[];
double   Downtrend[];
double t3;
//
//
//
int      TimeFrame;
datetime TimeArray[];
int      maxArrows;
int      SignalGap;
 
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
 
int init()
{
 
      SetIndexBuffer(0,DFull);
      SetIndexBuffer(1,KFull);
      SetIndexBuffer(2,Upper);
      SetIndexBuffer(3,Lower);
      SetIndexBuffer(4,Uptrend);
      SetIndexBuffer(5,Downtrend);
            
 
}
 
//+------------------------------------------------------------------+
 
int deinit()
{
   return(0);
}
 
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
 
int start()
{
   int    counted_bars=IndicatorCounted();
   int    limit;
   int    i;
   bool Longtrend=false, Shorttrend=false;
   
   limit=MathMax(Bars-counted_bars,TimeFrame/Period());
   ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
   
//if(Bars<100) {Print("bars less than 100"); return(0);}
   
   Print ("TEST SSTOCH :" , SSTOCInd(0)); //for testing
   
 
//-------------------------------------------------+   
//-------Stochastic Indikator----------------------+
//-------------------------------------------------+
 
double SSTOCInd (int bar)
   {
int    limit, i, y; 
 
   for(i=0,y=0; i<limit; i++)
      {
         if(Time[i]<TimeArray[y]) y++;
            KFull[i] = iStochastic(NULL,TimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_MAIN,y);
            DFull[i] = iStochastic(NULL,TimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,MODE_SIGNAL,y);
            return(KFull[i]); // this is the value who i need!
      }
 
   for(i=limit,y=0; i>=0; i--)
      {
         if (showBars)
            {
               Upper[i]     = EMPTY_VALUE;
               Lower[i]     = EMPTY_VALUE;
               while(true)
                  {
                     if (KFull[i] > overBought) { Upper[i]     = 100; break;}
                     if (KFull[i] < overSold)   { Lower[i]     = 100; break;}
                     if (KFull[i] > KFull[i+1]) { Uptrend[i]   = 100; break;}
                     if (KFull[i] < KFull[i+1]) { Downtrend[i] = 100; break;}
                        Uptrend[i]   = Uptrend[i+1];
                        Downtrend[i] = Downtrend[i+1];
                     break;
                  }
            }
         else
            {
               if (KFull[i] > overBought) { Upper[i] = KFull[i]; Upper[i+1] = KFull[i+1]; }
               else                       { Upper[i] = EMPTY_VALUE;
                                            if (Upper[i+2] == EMPTY_VALUE)
                                                Upper[i+1]  = EMPTY_VALUE; }
               if (KFull[i] < overSold)   { Lower[i] = KFull[i]; Lower[i+1] = KFull[i+1]; }
               else                       { Lower[i] = EMPTY_VALUE;
                                            if (Lower[i+2] == EMPTY_VALUE)
                                                Lower[i+1]  = EMPTY_VALUE; }
            }        
     } //end  for(i=limit,y=0; i>=0; i--)*/
   } // end double SSTOCInd (int Timeframe , double b,int bar)