DemarkNextDay





//+------------------------------------------------------------------+
//|                                                DemarkNextDay.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red



//---- input parameters

//---- buffers

double ExtMapBuffer1[];
double ExtMapBuffer2[];
 double H,L,C,X,O,LastHigh,LastLow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit,i,b;
      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)-1;



for (i=limit; i>=0;i--)
{ 

//if (High[i+1]>LastHigh) LastHigh=High[i+1];
//if (Low[i+1]<LastLow) LastLow=Low[i+1];

if (TimeDay(Time[i])!=TimeDay(Time[i+1]))
   {  if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
  //---- main loop
b = iBarShift(NULL,PERIOD_D1,Time[i+1]); 
H = iHigh (NULL,PERIOD_D1,b);
L = iLow (NULL,PERIOD_D1,b);
C = iClose (NULL,PERIOD_D1,b);
O = iOpen (NULL,PERIOD_D1,b);
if   (C>O)
X= ((2*H)+L+C)/2;
if   (O>C)
X= ((2*L)+H+C)/2;
if   (O==C)
X= ((2*C)+L+H)/2;

}
ExtMapBuffer1[i]=X-H;
ExtMapBuffer2[i]=X-L;

  } 
   return(0);
  }





Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: