//+------------------------------------------------------------------+
//|                                          dynamic zone stochastic |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1  DeepSkyBlue
#property indicator_color2  Red
#property indicator_color3  LimeGreen
#property indicator_color4  Red
#property indicator_color5  Gold
#property indicator_width1  2
#property indicator_style2  STYLE_DOT
#property indicator_style5  STYLE_DOT
#property indicator_minimum 0
#property indicator_maximum 100

//
//
//
//
//

#import "dynamicZone.dll"
   double dzBuy(double& sourceArray[],double probabiltyValue, int lookBack, int bars, int i );
   double dzSell(double& sourceArray[],double probabiltyValue, int lookBack, int bars, int i );
#import

//
//
//
//
//

extern int    pstLength              = 9;
extern int    pstX                   = 5;
extern int    pstSmooth              = 3;
extern int    DzLookBackBars         = 70;
extern double DzStartBuyProbability  = 0.10;
extern double DzStartSellProbability = 0.10;

//
//
//
//
//

double sto[];
double sig[];
double bli[];
double sli[];
double zli[];

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

int init()
{
   SetIndexBuffer(0,sto);
   SetIndexBuffer(1,sig);
   SetIndexBuffer(2,bli);
   SetIndexBuffer(3,sli);
   SetIndexBuffer(4,zli);
   
   //
   //
   //
   //
   //
      
   IndicatorShortName("Dynamic zone kase permission stochaastic ("+pstLength+","+pstX+","+pstSmooth+","+DzLookBackBars+","+DoubleToStr(DzStartBuyProbability,3)+","+DoubleToStr(DzStartSellProbability,3)+")");
   return(0);
}
int deinit() { return(0); }




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

int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = MathMin(Bars-counted_bars,Bars-1);

   //
   //
   //
   //
   //
   
   for(i=limit; i>=0; i--)
   {
      sto[i] = iCustom(NULL,0,"kase permission stochastic",pstLength,pstX,pstSmooth,0,i);
      sig[i] = iCustom(NULL,0,"kase permission stochastic",pstLength,pstX,pstSmooth,1,i);
      bli[i] = dzBuy (sto, DzStartBuyProbability,  DzLookBackBars, Bars, i);
      sli[i] = dzSell(sto, DzStartSellProbability, DzLookBackBars, Bars, i);
      zli[i] = dzSell(sto, 0.5,                    DzLookBackBars, Bars, i);
   }
   return(0);
}