DemarkNextDay

DemarkNextDay
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
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);
  }

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---