TF-altProjekte/Indukatoren/Heikin Ashi Kerzen/TF_I_HeikinAshi.mq5
super.admin 84cd1a7ab0 convert
2025-05-30 16:31:33 +02:00

102 lines
4.1 KiB
MQL5

//+------------------------------------------------------------------+
//| 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 5
#property indicator_plots 1
//--- plot Kerzen
//#property indicator_label1 "HA_Open;HA_High;HA_Low;HA_Close"
//#property indicator_type1 DRAW_COLOR_CANDLES
//#property indicator_color1 clrBlue,clrRed
//#property indicator_style1 STYLE_SOLID
//#property indicator_width1 4
//---
input string KerzenName="HA_Open;HA_High;HA_Low;HA_Close"; // Namen der Kerzenpunkte
input color KerzenNeutral=clrGray; // Kerzenfarbe Neutral
input color KerzenLong=clrBlue; // Kerzenfarbe Long
input color KerzenShort=clrRed; // Kerzenfarbe Short
//--- indicator buffers
double HA_Buffer_O[];
double HA_Buffer_H[];
double HA_Buffer_L[];
double HA_Buffer_C[];
double HA_Buffer_Colors[];
//+------------------------------------------------------------------+
//| 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_Buffer_Colors,INDICATOR_COLOR_INDEX);
//---
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_CANDLES);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,1);
PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,3);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,KerzenNeutral);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,KerzenLong);
PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,KerzenShort);
//PlotIndexSetInteger(0,PLOT_LINE_WIDTH,4);
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
PlotIndexSetString(0,PLOT_LABEL,KerzenName);
//---
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];
(open[0]<close[0])?HA_Buffer_Colors[0]=1:HA_Buffer_Colors[0]=2;
}
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_Buffer_Colors[i]=1:HA_Buffer_Colors[i]=2;
if(haO==haC) HA_Buffer_Colors[i]=0;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+