HEIKEN~1_001

Download script
Author: Copyright � 2006, Forex-TSD.com
HEIKEN~1_001

This tool is designed to enhance your trading charts by overlaying a specialized type of price movement analysis known as Heiken Ashi, which is combined with Moving Average logic. Its primary goal is to smooth out market "noise," making it easier for traders to identify the underlying trend of a currency pair or asset.

How the Logic Works

1. Data Smoothing (Moving Averages) Instead of looking at raw, erratic price candles, the script first calculates a Moving Average based on a specific period and method that you can customize. It identifies four key data points from this average: the opening price, closing price, the high, and the low. By using these averages as the foundation, the script filters out minor fluctuations to focus on the broader momentum.

2. Heiken Ashi Calculation The script then transforms those smoothed values into "Heiken Ashi" data. This is a unique way of visualizing candles where:

  • Opening Prices are derived from the average of previous periods.
  • Closing Prices are calculated by averaging the high, low, open, and close of the current period.
  • Highs and Lows are adjusted to ensure they encompass the full range of the price movement.

3. Visual Representation The script renders these results as histograms on your chart. It uses a color-coded system (Red and Light Sky Blue) to distinguish between upward and downward momentum. When the data shows an upward trend, it colors the bars one way; when it detects a downward trend, it switches to the other. This allows you to see the "flow" of the market more clearly than standard candles.

4. Automated Alerts Beyond just being a visual aid, the script includes an active monitoring system. It constantly checks the most recent price action (the current live bar). If the logic detects a significant shift in trend—specifically a clear "Buy" signal or a clear "Sell" signal based on the Heiken Ashi values—it will trigger an alert.

Depending on your settings, this can provide you with:

  • Audio Alerts: A sound notification to grab your attention immediately.
  • Pop-up Notifications: A message showing the specific symbol and timeframe where the trend change occurred.

In summary, this tool takes complex price data, cleans it through a moving average, converts it into a smoothed visual trend, and notifies you automatically when the market direction shifts.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
HEIKEN~1_001
//+------------------------------------------------------------------+
//|                                               Heiken Ashi Ma.mq4 |
//+------------------------------------------------------------------+
//|                                                      mod by Raff |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 LightSkyBlue
#property indicator_color3 Red
#property indicator_color4 LightSkyBlue
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
//---- parameters
extern int MaMetod  = 1;
extern int MaPeriod = 15;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double alertBar;
extern int SoundAlertMode = 1;
string Message;
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0,5);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double maOpen, maClose, maLow, maHigh;
   double haOpen, haHigh, haLow, haClose;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      maOpen=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_OPEN,pos);
      maClose=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_CLOSE,pos);
      maLow=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_LOW,pos);
      maHigh=iMA(NULL,0,MaPeriod,0,MaMetod,MODE_HIGH,pos);

      haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
      haClose=(maOpen+maHigh+maLow+maClose)/4;
      haHigh=MathMax(maHigh, MathMax(haOpen, haClose));
      haLow=MathMin(maLow, MathMin(haOpen, haClose));
      if (haOpen<haClose) 
        {
         ExtMapBuffer1[pos]=haLow;
         ExtMapBuffer2[pos]=haHigh;
        } 
      else
        {
         ExtMapBuffer1[pos]=haHigh;
         ExtMapBuffer2[pos]=haLow;
        } 
      ExtMapBuffer3[pos]=haOpen;
      ExtMapBuffer4[pos]=haClose;

	if (pos==0 && haOpen>haClose && Bars>alertBar)
	  {
  Message = " "+Symbol()+" "+Period()+" M"+Period()+": Heiken Ashi Signal for BUY";
	  if ( SoundAlertMode>0) Alert (Message," op= ",haOpen," cl= ",haClose," pos= ",pos); 
      alertBar = Bars;
	  }
      if (pos==0 && haOpen<haClose && Bars>alertBar)
	  {
	  Message = " "+Symbol()+" "+Period()+" M"+Period()+": Heiken Ashi Signal for SELL";
	  if ( SoundAlertMode>0 ) Alert (Message," op= ",haOpen," cl= ",haClose," pos= ",pos); 
     alertBar = Bars;
	  } 

 	   pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments