'CopyBuffer' - no one of the overloads can be applied to the function call

 
//+------------------------------------------------------------------+
//|                                                EMA Crossover.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3

//--- plot FastEMA
#property indicator_label1  "FastEMA"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot SlowEMA
#property indicator_label2  "SlowEMA"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrOrangeRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- plot SignalEMA
#property indicator_label3  "SignalEMA"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrLimeGreen
#property indicator_style3  STYLE_SOLID
#property indicator_width3  2

//--- input parameters

input int FastEMAPeriod=8; // Fast EMA period 
input int SlowEMAPeriod=16; // Slow EMA period 
input int SignalEMAPeriod=50; // Signal EMA period 

double FastEMABuffer[];
double SlowEMABuffer[];
double SignalEMABuffer[];

int handle_fast;
int handle_slow;
int handle_signal;

bool up_cross=false;
bool down_cross=false;

void OnInit()
{
    SetIndexBuffer(0,FastEMABuffer);
    SetIndexBuffer(1,SlowEMABuffer);
    SetIndexBuffer(2,SignalEMABuffer);

    handle_fast=iMA(_Symbol,_Period,FastEMAPeriod,0,MODE_EMA,PRICE_CLOSE);
    handle_slow=iMA(_Symbol,_Period,SlowEMAPeriod,0,MODE_EMA,PRICE_CLOSE);
    handle_signal=iMA(_Symbol,_Period,SignalEMAPeriod,0,MODE_EMA,PRICE_CLOSE);

}

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[])
{
    if(BarsCalculated(handle_fast)<rates_total || BarsCalculated(handle_slow)<rates_total || BarsCalculated(handle_signal)<rates_total)
        return(prev_calculated);

    ArraySetAsSeries(FastEMABuffer,true);
    ArraySetAsSeries(SlowEMABuffer,true);
    ArraySetAsSeries(SignalEMABuffer,true);

     CopyBuffer(handle_fast,0,rates_total-1,FastEMABuffer);
     CopyBuffer(handle_slow,0,rates_total-1,SlowEMABuffer);
     CopyBuffer(handle_signal,0,rates_total-1,SignalEMABuffer);
    
    //--- loop through the bars and check for crossover conditions
    for(int i=prev_calculated-1;i<rates_total && !IsStopped();i++)
    {
        //--- reset the flags
        up_cross=false;
        down_cross=false;

        //--- check for upward crossover when above signal EMA
        if(FastEMABuffer[i]>SlowEMABuffer[i] && FastEMABuffer[i-1]<=SlowEMABuffer[i-1] && FastEMABuffer[i]>SignalEMABuffer[i])
            up_cross=true;

        //--- check for downward crossover when below signal EMA
        if(FastEMABuffer[i]<SlowEMABuffer[i] && FastEMABuffer[i-1]>=SlowEMABuffer[i-1] && FastEMABuffer[i]<SignalEMABuffer[i])
            down_cross=true;

        //--- send notification if crossover occurs
        if(up_cross)
            Alert("Upward crossover at bar ",i,". Buy signal.");
        
        if(down_cross)
            Alert("Downward crossover at bar ",i,". Sell signal.");
    }

    return(rates_total);

I'm doing a simple EMA crossover indicator. There is only one error in the project, that is on line 79,80,81

CopyBuffer(handle_fast,0,rates_total-1,FastEMABuffer);
CopyBuffer(handle_slow,0,rates_total-1,SlowEMABuffer);
CopyBuffer(handle_signal,0,rates_total-1,SignalEMABuffer);

'CopyBuffer' - no one of the overloads can be applied to the function call. Screenshot attached

 

Read the documentation.

In each place you have four (4) arguments in your code.

All three variants of the CopyBuffer expect five (5) arguments.

 
Drazen Penic #:

Read the documentation.

In each place you have four (4) arguments in your code.

All three variants of the CopyBuffer expect five (5) arguments.

I'm stupid haha. I used a '-' instead of ',' when seprating `rates_total` and the count `1`. Thanks for poiting that out, I'm tired.