Heiken Ashi#





//+------------------------------------------------------------------+
//|                                                 Heiken AshiR.mq4 |
//|                      Copyright c 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| For Heiken Ashi we recommend next chart settings ( press F8 or   |
//| select on menu 'Charts'->'Properties...'):                       |
//|  - On 'Color' Tab select 'Black' for 'Line Graph'                |
//|  - On 'Common' Tab disable 'Chart on Foreground' checkbox and    |
//|    select 'Line Chart' radiobutton                               |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//---- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
#property indicator_chart_window 
//---- êîëè÷åñòâî èíäèêàòîðíûõ áóôôåðîâ
#property indicator_buffers 4 
//---- öâåòà èíäèêàòîðà 
#property indicator_color1 Red  
#property indicator_color2 LimeGreen 
#property indicator_color3 Red
#property indicator_color4 LimeGreen
//---- òîëùèíà èíäèêàòîðíûõ ëèíèé
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3 
#property indicator_width4 3
//---- èíäèêàòîðíûå áóôôåðû
double L.Buffer[];
double H.Buffer[];
double O.Buffer[];
double C.Buffer[];
//---- ïåðåìåííûå ñ ïëàâàþùåé òî÷êîé  
double haOpen, haHigh, haLow, haClose;
//+------------------------------------------------------------------+
//| Heiken AshiR initialization function                             |
//+------------------------------------------------------------------+
int init()
  {
//---- ñòèëü èçîáðàæåíèÿ èíäèêàòîðà
   SetIndexStyle(0,DRAW_HISTOGRAM,0);
   SetIndexStyle(1,DRAW_HISTOGRAM,0);
   SetIndexStyle(2,DRAW_HISTOGRAM,0);
   SetIndexStyle(3,DRAW_HISTOGRAM,0);
//---- óñòàíîâêà íîìåðà áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò îòðèñîâûâàòüñÿ èíäèêàòîð  
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
//---- 4 èíäèêàòîðíûõ áóôôåðà èñïîëüçîâàíû äëÿ ñ÷¸òà
   SetIndexBuffer(0,L.Buffer);
   SetIndexBuffer(1,H.Buffer);
   SetIndexBuffer(2,O.Buffer);
   SetIndexBuffer(3,C.Buffer);
//---- çàâåðøåíèå èíèöèàëèçàöèè
   return(0);
  }
//+------------------------------------------------------------------+
//| Heiken AshiiR teration function                                  |
//+------------------------------------------------------------------+
int start()
  {
if (Bars<=10) return(0);
//----+ Ââåäåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ
int bar,counted_bars=IndicatorCounted(); 
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
if (counted_bars<0)return(-1);
//---- ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí 
//(áåç ýòîãî ïåðåñ÷¸òà äëÿ counted_bars ôóíêöèÿ JJMASeries áóäåò ðàáîòàòü íåêîððåêòíî!!!)
if (counted_bars>0) counted_bars--;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò íîâûõ áàðîâ
bar=Bars-counted_bars-1;
if (bar>Bars-2)bar=Bars-2;
//----
while(bar>=0)
     {
      haOpen=(O.Buffer[bar+1]+C.Buffer[bar+1])/2;
      haClose=(Open[bar]+High[bar]+Low[bar]+Close[bar])/4;
      haHigh=MathMax(High[bar], MathMax(haOpen, haClose));
      haLow=MathMin(Low[bar], MathMin(haOpen, haClose));
      if (haOpen<haClose) 
        {
         L.Buffer[bar]=haLow;
         H.Buffer[bar]=haHigh;
        } 
      else
        {
         L.Buffer[bar]=haHigh;
         H.Buffer[bar]=haLow;
        } 
      O.Buffer[bar]=haOpen;
      C.Buffer[bar]=haClose;
 	   bar--;
     }
//----
   return(0);
  }
//+-------------------------------------------------------------------------+





Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains open prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: