Navigation´╝ÜHome > Content >

TP_HeikenAshi.mq4

Time: 2015-06-15 | Download file:TP_HeikenAshi.mq4

//+------------------------------------------------------------------+
//|                                                TP_HeikenAshi.mq4 |
//|                                                      Ron Mauldin |
//|                                                  http://fx41.com |
//+------------------------------------------------------------------+
#property copyright "Ron Mauldin"
#property link      "http://fx41.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

//----
color color1 = Red;
color color2 = White;
color color3 = Red;
color color4 = White;

//---- buffers
double haDN1[];
double haUP1[];
double haDN2[];
double haUP2[];

int init(){
 SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1);
 SetIndexBuffer(0, haDN1);//Red
 SetIndexDrawBegin(0,10);
 SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2);
 SetIndexBuffer(1, haUP1);//White
 SetIndexDrawBegin(1,10);
 SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, color3);
 SetIndexBuffer(2, haDN2);//Red
 SetIndexDrawBegin(2,10);
 SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, color4);
 SetIndexBuffer(3, haUP2);//White
 SetIndexDrawBegin(3,10);
 return(0);
}
int deinit(){return(0);}
int start(){
 double haOpen, haHigh, haLow, haClose;
 int counted_bars = IndicatorCounted();
 if(counted_bars<0) counted_bars=0;
 if(counted_bars>0) counted_bars--;
 int limit = (Bars - 1 - counted_bars);
 for(int bar = limit; bar >= 0; bar--){  
//haOpen=(haDN2[bar+1]+haUP2[bar+1])/2; This standard HA was replaced by a 4 period HA
  haOpen=((((((Open[bar+3]+High[bar+3]+Low[bar+3]+Close[bar+3])/4)+((Open[bar+2]+High[bar+2]+Low[bar+2]+Close[bar+2])/4))/2)+((Open[bar+1]+High[bar+1]+Low[bar+1]+Close[bar+1])/4))/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        

Recommend