Help with "Zero Devide" error and Gost chart !!!

 
Hi there, I am atttempting to code the Double Stochastic Indicator for MT4...the indicator when shown looks fine, just like it should. Only trouble is, when I add the indicator to a new chart, the indicator window is blank...when I go tot the MetaEditor and compile the indicator twice, the indicator then appears in the indicator window on the chosen chart. If if then choose to change a setting in die indicator properties from the chart, the same effect is generated...blank indicator window until recompiled twice again...

It would appear as if the is a bug in my loop code or some initialization problem...please review my code and please help me, I would honestly appreciate this.

The regular Metastock code for this indicator is very simply:

Double Stochastic - 10 Periode

Period P1:=Mov(((C-LLV(L,10))/(HHV(H,10)-LLV(L,10)))*100,3,E);
Mov(((P1-LLV(P1,10))/(HHV(P1,10)-LLV(P1,10)))*100,3,E)


My attempt to code this follows:

#property link      ""
#property  indicator_buffers 1
#property indicator_separate_window
#property indicator_color1 Yellow

//---- buffers
extern int Sl = 3;
extern int Pr = 10;

double Dst[];
double St[];
double StArray1[];
double StArray2[];
double StArray3[];
double DstArray1[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,Dst);
   SetIndexBuffer(1,St);
   SetIndexBuffer(2,StArray1);
   SetIndexBuffer(3,StArray2);
   SetIndexBuffer(4,StArray3);
   SetIndexBuffer(5,DstArray1);
   
   SetIndexLabel(0,"Double Stochastic");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
//---- TODO: add your code here
   for(int i=limit;i>=0;i--)
   {
   StArray1[i]= (Close[i]-Low[Lowest(NULL,0,MODE_LOW,Pr,i)]);
   StArray2[i]= High[Highest(NULL,0,MODE_HIGH,Pr,i)] - StArray1[i];
   }
   
   for (i=limit-Pr;i>=0;i--)
   {
     StArray3[i]= (StArray1[i]/StArray2[i])*100;
     St[i]=iMAOnArray(StArray3,0,Sl,0,MODE_EMA,i);
   }
   for (i=limit-Pr-1;i>=0;i--)
   {   
   DstArray1[i]=((St[i]-St[ArrayMinimum(St,Pr,i)])/(St[ArrayMaximum(St,Pr,i)]-St[ArrayMinimum(St,Pr,i)]))*100;
   Dst[i]=iMAOnArray(DstArray1,0,Sl,0,MODE_EMA,i);
   }
   return(0);
  }



 
Nevermind, I came right.
Reason: