Author: macdik
Indicators Used
MACD Histogram
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
macdik
//+------------------------------------------------------------------+
//|                                                        macdik.mq4 |
//|                                    Copyright (C) 2010 Vikon      |
//|                        |
//+------------------------------------------------------------------+
#property copyright "macdik" 

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Red
//---- input parameters

//---- buffers
double b[],s[];
string d;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,b);
   SetIndexStyle(0,DRAW_HISTOGRAM,0,4);

   SetIndexBuffer(1,s);
   SetIndexStyle(1,DRAW_LINE,0,1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("ADX");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//int i=Bars;
   double b0,b1,b2,i1,i2,s0,s1,s2;
   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+2;
   int i=limit;

   while(i>=0)
     {
      i1=i+1;
      i2=i+2;

      b0=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
      b1=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i1);
      b2=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i2);
      s0=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,i);

      s[i]=(b0-s0)*10000;

      b[i]=((b1-b2)-(b1-b0))*10000;
      //(((b1-s1)-(b2-s2))-((b1-s1)-(b0-s0)))*10000;
      i--;
     }

   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 ---