//+------------------------------------------------------------------+
//|                                                 3D Oscilator.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Author - Luis Damiani. Ramdass - Conversion only"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 White
#property indicator_color3 Chartreuse
#property indicator_color4 Red
//---- input parameters

extern int K_Period=12; //15 / 5 /5 vir die 1-m !!!5M = 15/3/5.
extern int D_Period=4;
extern int Slowing=3;



//---- buffers
double sig1n[];
double sig2n[];
double upX[],dnX[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,sig1n);
   SetIndexBuffer(1,sig2n);

   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,233);  // 159
   SetIndexBuffer(2,upX);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,234);  //159
   SetIndexBuffer(3,dnX);
//----
  /// SetIndexDrawBegin(0,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
  // SetIndexDrawBegin(1,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
  // SetIndexDrawBegin(2,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
  // SetIndexDrawBegin(3,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| CCI_Woodies                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,i2,counted_bars=IndicatorCounted();
   double rsi,maxrsi,minrsi,storsi,E3D,
   sig1,sig2,sk,ss,sk2;
   double cs;
   bool init=true;
   
   //----
   //cs= D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth;
   if(Bars<=cs) return(0);

  
   //};

   //---- initial zero
   if(counted_bars<1)
      {
      for(i=1;i<=cs;i++) sig1n[Bars-i]=0.0;
      for(i=1;i<=cs;i++) sig2n[Bars-i]=0.0;
      for(i=1;i<=cs;i++) upX[Bars-i]=0.0;
      for(i=1;i<=cs;i++) dnX[Bars-i]=0.0;
      }
      
   i=Bars-cs-1;
   
   if (counted_bars>=cs) i=1300; //i=Bars-counted_bars-1;
   while (i>=0)
      {
      
     // rsi=iRSI(NULL,0,D1RSIPer,PRICE_CLOSE,i);
      //maxrsi=rsi;
      //minrsi=rsi;

      
         
      //storsi=((rsi-minrsi)/(maxrsi-minrsi)*200-100);
     // E3D=hot*iCCI(NULL,0,D3tunnelPer,PRICE_TYPICAL,i)+(1-hot)*storsi;
      sig2n[i]=(iStochastic(NULL,0,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_SIGNAL,i));
      sig1n[i]=(iStochastic(NULL,0,K_Period,D_Period,Slowing,MODE_SMA,0,MODE_MAIN,i));
      sig1=sig1n[i];
      sig2=sig2n[i];
      
      if (sig1n[i]>sig2n[i] && sig1n[i+1]<sig2n[i+1] ) upX[i]=sig2n[i]-15;
      if (sig1n[i]<sig2n[i] && sig1n[i+1]>sig2n[i+1] ) dnX[i]=sig2n[i]+15;

      i--;
      }
      
   return(0);
   }
//+------------------------------------------------------------------+