mExperement

Author: Copyright � 2011, Korwin
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
mExperement
//+------------------------------------------------------------------+
//|                                                  !Experement.mq4 |
//|                                         Copyright © 2011, Korwin |
//|                                             korwin-kor@yandex.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Korwin"
#property link      "korwin-kor@yandex.ru"

#property indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Green



double x,y,buf0[],buf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(8);

   SetIndexBuffer(0,buf0); SetIndexStyle(0,DRAW_LINE); SetIndexEmptyValue(0,0);
   SetIndexBuffer(1,buf1); SetIndexStyle(1,DRAW_LINE); SetIndexEmptyValue(1,0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+1;

   for(int i=limit-1; i>=0; i--)
     {
      if(buf0[i+1]==0 && buf1[i+1]==0)
        {
         if(Close[i+1]>Open[i+1]) buf1[i+1]=Low[i+1];
         if(Close[i+1]<Open[i+1]) buf0[i+1]=High[i+1];
        }
      if(buf0[i+1]>0)
        {
         if(buf0[i+1]>Close[i+1]) buf0[i]=buf0[i+1]-(High[i+1]-(High[i+1]-(High[i+1]-Low[i+1])/2))/2;
         else
           {
            buf0[i]=0;
            buf1[i+1]=Low[i+1];
            buf1[i]=buf1[i+1]+((Low[i+1]+(High[i+1]-Low[i+1])/2)-Low[i+1])/2;
           }
        }
      if(buf1[i+1]>0)
        {
         if(buf1[i+1]<Close[i+1]) buf1[i]=buf1[i+1]+((Low[i+1]+(High[i+1]-Low[i+1])/2)-Low[i+1])/2;
         else
           {
            buf1[i]=0;
            buf0[i+1]=High[i+1];
            buf0[i]=buf0[i+1]-(High[i+1]-(High[i+1]-(High[i+1]-Low[i+1])/2))/2;
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments