Heiken Ashi_CL_weiss-grau

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
Heiken Ashi_CL_weiss-grau

This tool is designed to transform the way price action appears on your trading charts by converting standard price data into a specialized visual format known as Heiken Ashi candles. Unlike traditional candles, which represent the raw high, low, open, and close of a specific time period, this script filters out "market noise" to provide a smoother, more trend-oriented perspective.

How the Logic Works

The script processes your historical market data through a mathematical smoothing process. Instead of simply plotting the raw price points, it calculates four distinct components for every candle:

  • Price Averaging: The tool takes the current price movement and blends it with the values from the previous period. This ensures that each new candle is structurally linked to the one before it, creating a continuous flow rather than isolated price jumps.
  • Dynamic Open/Close Points: It calculates an "Average Open" and "Average Close" for each bar. By doing this, the script helps traders see the underlying momentum of the market—showing whether the price is moving with strength or struggling against a trend.
  • Extreme Boundary Detection: The tool automatically identifies the highest and lowest points of each period by comparing the actual market peaks/valleys against the new averaged values. This ensures that the visual representation remains grounded in reality while still benefiting from the smoothing effect.

Visual Representation

The script organizes these calculations into four distinct layers to provide a clear visual experience:

  1. Trend Identification: The logic differentiates between "up" and "down" movements by comparing the averaged open and close values.
  2. Color Coding: Based on whether the market shows upward or downward momentum, the script assigns specific colors (configured as SlateGray and White) to the candles. This allows you to see at a glance if the price direction is sustained.
  3. Visual Weight: The script uses different line thicknesses for different parts of the candle data, highlighting the core body of the price movement while providing a secondary visual cue for the high and low boundaries.

Summary of Purpose

The primary goal of this logic is clarity. By converting volatile "raw" data into smoothed "Heiken Ashi" values, the script helps traders identify the general direction of a trend more easily, making it easier to spot when a move is gaining strength or beginning to lose steam.

Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Heiken Ashi_CL_weiss-grau
//+------------------------------------------------------------------+
//|                                                  Heiken Ashi.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 SlateGray
#property indicator_color2 White
#property indicator_color3 SlateGray
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

//----
extern color color1 = SlateGray;
extern color color2 = White;
extern color color3 = SlateGray;
extern color color4 = White;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, color3);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, color4);
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   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)
     {
      haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
      haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
      haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
      haLow=MathMin(Low[pos], 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;
 	   pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments