Hello
I'm a newbie at MT4 coding. I'm trying to help a friend set up some indicators and EA's. This is one code of an indicator and for some reason it does not display on the screen - and we can't tell why. Can anyone assist, please -- and Thank You in advance!!!
//------------------+
//Ehlers_ZeroLag_Filter.mq4
//------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//---plot zerolag filter
#property indicator_label1 "ZeroLagFit"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLimeGreen
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//---input paramaters
input double alpha = .33;
//---indicator buffers
double ZeroLagFiltBuffer[];
double Price[];
int OnInit()
{
//---indicator buffer mapping
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ZeroLagFiltBuffer);
SetIndexDrawBegin(0,DRAW_LINE);
return(INIT_SUCCEEDED);
}
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[])
{
//---
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(Price,true);
ArraySetAsSeries(ZeroLagFiltBuffer,true);
int bars = rates_total - 1;
if(prev_calculated > 0) bars = rates_total - prev_calculated;
for(int i = bars; i >= 0; i--)
{
Price[i] = (high[i] + low[i]) * .5;
ZeroLagFiltBuffer[i] = alpha * (Price[i] + .5 * (Price[i] - Price[i+3])) + (1 - alpha) * ZeroLagFiltBuffer[i+1];
}
//---return value of prev_calculated for next call
return(rates_total);
I'm a newbie at MT4 coding. I'm trying to help a friend set up some indicators and EA's. This is one code of an indicator and for some reason it does not display on the screen - and we can't tell why. Can anyone assist, please -- and Thank You in advance!!!
//------------------+
//Ehlers_ZeroLag_Filter.mq4
//------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//---plot zerolag filter
#property indicator_label1 "ZeroLagFit"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLimeGreen
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//---input paramaters
input double alpha = .33;
//---indicator buffers
double ZeroLagFiltBuffer[];
double Price[];
int OnInit()
{
//---indicator buffer mapping
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ZeroLagFiltBuffer);
SetIndexDrawBegin(0,DRAW_LINE);
return(INIT_SUCCEEDED);
}
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[])
{
//---
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
ArraySetAsSeries(Price,true);
ArraySetAsSeries(ZeroLagFiltBuffer,true);
int bars = rates_total - 1;
if(prev_calculated > 0) bars = rates_total - prev_calculated;
for(int i = bars; i >= 0; i--)
{
Price[i] = (high[i] + low[i]) * .5;
ZeroLagFiltBuffer[i] = alpha * (Price[i] + .5 * (Price[i] - Price[i+3])) + (1 - alpha) * ZeroLagFiltBuffer[i+1];
}
//---return value of prev_calculated for next call
return(rates_total);