TF-altProjekte/Indukatoren/Heikin Ashi Kerzen/TF_I_HeikinAshi-v2.mq5

102 lines
7.6 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 16:31:33 +02:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| TF_I_HeikinAshi.mq5 |
//| Thorsten Fischer Copyright 2019-2020 |
//| https://mql5.tfsystem.de |
//+------------------------------------------------------------------+
#property copyright "Thorsten Fischer Copyright 2019-2020"
#property link "https://mql5.tfsystem.de"
#property version "1.00"
#property description "Das ist der Heikin Ashi Indikator"
#property description "erstellt von Thorsten Fischer"
#property strict
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_plots 5
//--- plot Kerzendocht
#property indicator_label1 "HA_High;HA_Low"
#property indicator_type1 DRAW_CANDLES
//#property indicator_color1 clrBlue,clrRed
//#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot Kerzenk<EFBFBD>rper
//#property indicator_label2 "HA_Open;HA_Close"
//#property indicator_type2 DRAW_COLOR_CANDLES
//#property indicator_color2 clrBlue,clrRed
//#property indicator_style2 STYLE_SOLID
//#property indicator_width2 4
//--- indicator buffers
double HA_Buffer_O[];
double HA_Buffer_H[];
double HA_Buffer_L[];
double HA_Buffer_C[];
double HA_Colors[];
//double HA_Shadow[];
//double HA_Retracement[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
IndicatorSetString(INDICATOR_SHORTNAME,"TF Heikin Ashi Kerzen");
//--- indicator buffers mapping
SetIndexBuffer(0,HA_Buffer_O,INDICATOR_DATA);
SetIndexBuffer(1,HA_Buffer_H,INDICATOR_DATA);
SetIndexBuffer(2,HA_Buffer_L,INDICATOR_DATA);
SetIndexBuffer(3,HA_Buffer_C,INDICATOR_DATA);
SetIndexBuffer(4,HA_Colors,INDICATOR_COLOR_INDEX);
//SetIndexBuffer(5,HA_Shadow,INDICATOR_DATA);
//SetIndexBuffer(6,HA_Retracement,INDICATOR_DATA);
//---
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
int i=prev_calculated-1;
double haO,haH,haL,haC;
//---
if(i==-1)
{
i=1;
HA_Buffer_O[0]=open[0];
HA_Buffer_H[0]=high[0];
HA_Buffer_L[0]=low[0];
HA_Buffer_C[0]=close[0];
//HA_Shadow[0]=0.0;
//HA_Retracement[0]=rates_total;
}
for(i; i<rates_total && !IsStopped(); i++)
{
haO=(HA_Buffer_O[i-1]+HA_Buffer_C[i-1])/2;
haC=(open[i]+high[i]+low[i]+close[i])/4;
haH=MathMax(high[i],MathMax(haO,haC));
haL=MathMin(low[i],MathMin(haO,haC));
HA_Buffer_O[i]=haO;
HA_Buffer_H[i]=haH;
HA_Buffer_L[i]=haL;
HA_Buffer_C[i]=haC;
(haO<haC)?HA_Colors[i]=0.0:HA_Colors[i]=1.0;
//HA_Shadow[i]=i;
//HA_Retracement[i]=rates_total;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+