Indicator Compiling error
-
Morning everyone.. Could someone please help me finding why and fix errors in this indicator when compiling? Thank you
0_1640506669608_BollingerzFibonacci.mq5

-
@alphaomega I cannot even comipile it on my terminal. Are you sure this is the correct file?
-
@l-andorrà .. Yes it is the correct file.. It starts of like this

//+------------------------------------------------------------------+
//| Bollinger-Fibonacci.mq5 |
//| EACompared.com |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "EACompared.com"
#property link "http://www.mql5.com"
#property version "1.00"
#include <MovingAverages.mqh>
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_plots 7
//--- plot UpperBand3
#property indicator_label1 "UpperBand3"
#property indicator_type1 DRAW_LINE
#property indicator_color1 DarkOliveGreen
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot UpperBand2
#property indicator_label2 "UpperBand2"
#property indicator_type2 DRAW_LINE
#property indicator_color2 DarkGreen
#property indicator_style2 STYLE_DASH
#property indicator_width2 1
//--- plot UpperBand1
#property indicator_label3 "UpperBand1"
#property indicator_type3 DRAW_LINE
#property indicator_color3 SeaGreen
#property indicator_style3 STYLE_DASH
#property indicator_width3 1
//--- plot MidPoint
#property indicator_label4 "MidPoint"
#property indicator_type4 DRAW_LINE
#property indicator_color4 DarkBlue
#property indicator_style4 STYLE_SOLID
#property indicator_width4 1
//--- plot LowerBand1
#property indicator_label5 "LowerBand1"
#property indicator_type5 DRAW_LINE
#property indicator_color5 SeaGreen
#property indicator_style5 STYLE_DASH
#property indicator_width5 1
//--- plot LowerBand2
#property indicator_label6 "LowerBand2"
#property indicator_type6 DRAW_LINE
#property indicator_color6 DarkGreen
#property indicator_style6 STYLE_DASH
#property indicator_width6 1
//--- plot LowerBand3
#property indicator_label7 "LowerBand3"
#property indicator_type7 DRAW_LINE
#property indicator_color7 DarkOliveGreen
#property indicator_style7 STYLE_SOLID
#property indicator_width7 1
//--- input parameters
input ENUM_APPLIED_PRICE Pr=PRICE_CLOSE;
input int Periods=20;
input ENUM_MA_METHOD MAType=MODE_SMA;
input float Factor1=1.618;
input float Factor2=2.618;
input float Factor3=4.236;
//--- input parameters
input int InpAtrPeriod=14; // ATR period
//--- indicator buffers//--- global variable
int ExtPeriodATR;
int ExtBandsPeriod;
int ExtPlotBegin=0;
//--- indicator buffers
double UpperBand3Buffer[];
double UpperBand2Buffer[];
double UpperBand1Buffer[];
double MidPointBuffer[];
double LowerBand1Buffer[];
double LowerBand2Buffer[];
double LowerBand3Buffer[];
double ExtATRBuffer[];
double ExtTRBuffer[];//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- check for input values
if(Periods<2)
{
ExtBandsPeriod=20;
printf("Incorrect value for input variable Periods=%d. Indicator will use value=%d for calculations.",Periods,ExtBandsPeriod);
}
else ExtBandsPeriod=Periods;
//--- indicator buffers mapping
SetIndexBuffer(0,ExtATRBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(1,ExtTRBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(0,UpperBand3Buffer,INDICATOR_DATA);
SetIndexBuffer(1,UpperBand2Buffer,INDICATOR_DATA);
SetIndexBuffer(2,UpperBand1Buffer,INDICATOR_DATA);
SetIndexBuffer(3,MidPointBuffer,INDICATOR_DATA);
SetIndexBuffer(4,LowerBand1Buffer,INDICATOR_DATA);
SetIndexBuffer(5,LowerBand2Buffer,INDICATOR_DATA);
SetIndexBuffer(6,LowerBand3Buffer,INDICATOR_DATA);
//--- set index labels
PlotIndexSetString(0,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Middle");
PlotIndexSetString(3,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Upper");
PlotIndexSetString(6,PLOT_LABEL,"Bands("+string(ExtBandsPeriod)+") Lower");
//--- indicator name
IndicatorSetString(INDICATOR_SHORTNAME,"BB-Fibonacci");
//--- indexes draw begin settings
ExtPlotBegin=ExtBandsPeriod-1;
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(5,PLOT_DRAW_BEGIN,ExtBandsPeriod);
PlotIndexSetInteger(6,PLOT_DRAW_BEGIN,ExtBandsPeriod);
//--- number of digits of indicator value
IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1);
//---
return(0);
}
//+------------------------------------------------------------------+
//| 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 &TickVolume[],
const long &Volume[],
const int &Spread[],
const int begin,
const double &price[])
{
//--- variables
int pos;
//--- indexes draw begin settings, when we've recieved previous begin
if(ExtPlotBegin!=ExtBandsPeriod+begin)
{
ExtPlotBegin=ExtBandsPeriod+begin;
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(5,PLOT_DRAW_BEGIN,ExtPlotBegin);
PlotIndexSetInteger(6,PLOT_DRAW_BEGIN,ExtPlotBegin);
}
{
int i,limit;
//--- check for bars count
if(rates_total<=ExtPeriodATR)
return(0); // not enough bars for calculation
//--- preliminary calculations
if(prev_calculated==0)
{
ExtTRBuffer[0]=0.0;
ExtATRBuffer[0]=0.0;
//--- filling out the array of True Range values for each period
for(i=1;i<rates_total;i++)
ExtTRBuffer[i]=MathMax(High[i],Close[i-1])-MathMin(Low[i],Close[i-1]);
//--- first AtrPeriod values of the indicator are not calculated
double firstValue=0.0;
for(i=1;i<=ExtPeriodATR;i++)
{
ExtATRBuffer[i]=0.0;
firstValue+=ExtTRBuffer[i];
}
//--- calculating the first value of the indicator
firstValue/=ExtPeriodATR;
ExtATRBuffer[ExtPeriodATR]=firstValue;
limit=ExtPeriodATR+1;
}
else limit=prev_calculated-1;
//--- the main loop of calculations
for(i=limit;i<rates_total;i++)
{
ExtTRBuffer[i]=MathMax(High[i],Close[i-1])-MathMin(Low[i],Close[i-1]);
ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-ExtPeriodATR])/ExtPeriodATR;
}
//--- return value of prev_calculated for next call
return(rates_total);
}//--- check for bars count
if(rates_total<ExtPlotBegin)
{return(0); }//--- starting calculation
if(prev_calculated>1) pos=prev_calculated-1;
else pos=0;
//--- main cycle
for(int i=pos;i<rates_total;i++)
{
//--- middle line
MidPointBuffer[i]=SimpleMA(i,ExtBandsPeriod,price);
//--- upper band 3
UpperBand3Buffer[i]=MidPointBuffer[i]+(Factor3ExtATRBuffer[i]);
//--- upper band 2
UpperBand3Buffer[i]=MidPointBuffer[i]+(Factor2ExtATRBuffer[i]);
//--- upper band 1
UpperBand3Buffer[i]=MidPointBuffer[i]+(Factor1ExtATRBuffer[i]);
//--- lower band 1
LowerBand1Buffer[i]=MidPointBuffer[i]-(Factor1ExtATRBuffer[i]);
//--- lower band 2
LowerBand2Buffer[i]=MidPointBuffer[i]-(Factor2ExtATRBuffer[i]);
//--- lower band 3
LowerBand3Buffer[i]=MidPointBuffer[i]-(Factor3ExtATRBuffer[i]);
//---
}
//---- OnCalculate done. Return new prev_calculated.
return(rates_total);
}//---

-
@l-andorrà I found another one that is working.. Thank you
https://www.mql5.com/en/code/18034 -
@alphaomega Thank you for sharing.