Heiken_Ashi_Smoothed_dunkel

Download script
Author: Copyright � 2006, Forex-TSD.com

Technical Logic Overview: Heiken Ashi Smoothed

This script is designed to provide a refined visual representation of price action on your trading charts. By combining two distinct types of mathematical smoothing, it aims to filter out "market noise"—those small, erratic price fluctuations that can often lead to false signals—allowing for a clearer view of the underlying trend.

How the Logic Works

The indicator processes data through a multi-layered calculation sequence:

1. Primary Trend Smoothing Instead of looking at raw, jagged price candles, the script first calculates Moving Averages (MA) for the open, high, low, and close prices. By using specific periods and methods defined in the settings, it creates a "smoothed" baseline of the market's recent history.

2. Heiken Ashi Integration The script then applies Heiken Ashi logic to these smoothed averages. Unlike standard candles, Heiken Ashi candles use an averaging formula to determine their boundaries. Specifically:

  • Open Prices: These are calculated as the average of the previous candle's high and low values.
  • Close Prices: These represent the midpoint of the current period's price range.
  • High/Low Extremes: The script automatically adjusts the "wick" (the lines extending from the candles) to ensure they reflect the true extremes between the calculated open and close prices.

3. Secondary Refinement To ensure the visual output is as clean as possible, a final layer of smoothing is applied. The script takes the results from the Heiken Ashi calculations and runs them through a second Moving Average calculation. This double-smoothing effect creates the "Smoothed" characteristic of the indicator, resulting in a more fluid and less volatile visual display.

Visual Representation

The final output is rendered as a series of histograms on your chart. By using different colors (FireBrick and DarkSlateBlue), the indicator helps traders quickly identify:

  • Trend Direction: The shift in colors typically signals a change in momentum.
  • Momentum Strength: The shape and size of the smoothed bars indicate whether a trend is accelerating or losing steam.

Summary for the User

Essentially, this tool acts as a "filter." It takes messy market data, smooths it out using moving averages, converts it into a Heiken Ashi format to highlight price movement trends, and then applies one final polish to make the trend easier to read at a glance. This allows traders to focus on the bigger picture rather than getting distracted by minor price ticks.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
Heiken_Ashi_Smoothed_dunkel
//+------------------------------------------------------------------+
//|                                         Heiken Ashi Smoothed.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 FireBrick
#property indicator_color2 DarkSlateBlue
#property indicator_color3 FireBrick
#property indicator_color4 DarkSlateBlue
//---- parameters
extern int MaMetod  = 2;
extern int MaPeriod = 6;
extern int MaMetod2  = 3;
extern int MaPeriod2 = 2;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   IndicatorBuffers(8);

   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, FireBrick);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, DarkSlateBlue);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, FireBrick);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, DarkSlateBlue);
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0,5);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexBuffer(7,ExtMapBuffer8);
//---- 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;
   int pos2=pos;
   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=(ExtMapBuffer5[pos+1]+ExtMapBuffer6[pos+1])/2;
      haClose=(maOpen+maHigh+maLow+maClose)/4;
      haHigh=MathMax(maHigh, MathMax(haOpen, haClose));
      haLow=MathMin(maLow, MathMin(haOpen, haClose));

      if (haOpen<haClose) 
        {
         ExtMapBuffer7[pos]=haLow;
         ExtMapBuffer8[pos]=haHigh;
        } 
      else
        {
         ExtMapBuffer7[pos]=haHigh;
         ExtMapBuffer8[pos]=haLow;
        } 
      ExtMapBuffer5[pos]=haOpen;
      ExtMapBuffer6[pos]=haClose;

 	   pos--;
     }
     
   int i;
   for(i=0; i<pos2; i++) ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer7,Bars,MaPeriod2,0,MaMetod2,i);
   for(i=0; i<pos2; i++) ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer8,Bars,MaPeriod2,0,MaMetod2,i);
   for(i=0; i<pos2; i++) ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer5,Bars,MaPeriod2,0,MaMetod2,i);
   for(i=0; i<pos2; i++) ExtMapBuffer4[i]=iMAOnArray(ExtMapBuffer6,Bars,MaPeriod2,0,MaMetod2,i);

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

ObjectCreate("freefxsystem", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("freefxsystem", "www.freefxsystem.com", 11, "Lucida Handwriting", RoyalBlue);
   ObjectSet("freefxsystem", OBJPROP_CORNER, 2);
   ObjectSet("freefxsystem", OBJPROP_XDISTANCE, 5);
   ObjectSet("freefxsystem", OBJPROP_YDISTANCE, 10);
   return(0);

Comments