bExperement_v_0_0_2

Author: Copyright � 2011, Korwin
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
bExperement_v_0_0_2
//+------------------------------------------------------------------+
//|                                                  !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

extern int divisor=6;

double 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 i;
   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--;

      for(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]-Low[i+1])/divisor;
            else
              {
               buf0[i]=0;
               buf1[i+1]=Low[i+1];
               buf1[i]=buf1[i+1]+(High[i+1]-Low[i+1])/divisor;
              }
           }
         if(buf1[i+1]>0)
           {
            if(buf1[i+1]<Close[i+1]) buf1[i]=buf1[i+1]+(High[i+1]-Low[i+1])/divisor;
            else
              {
               buf1[i]=0;
               buf0[i+1]=High[i+1];
               buf0[i]=buf0[i+1]-(High[i+1]-Low[i+1])/divisor;
              }
           }
        }

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

Comments