"zero divide in" error with indicator in mql4

 
//+------------------------------------------------------------------+
//|                                                      z_score.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot zscore
#property indicator_label1  "zscore"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRoyalBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- input parameters
input string   symbol1="AUDUSD";
input string   symbol2="NZDUSD";
input int      ma_zscore=21;
//--- indicator buffers
double         zscoreBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,zscoreBuffer);
   
//---
   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[])
  {
//---
   double diff[1];
   
   for(int i=0; i<Bars; i++)
   {
    diff[i] = iClose(symbol1,1440,i) - 1.07767 * iClose(symbol2,1440,i);
    zscoreBuffer[i] = iMAOnArray(diff,0,1,0,MODE_SMA,i) - iMAOnArray(diff,0,ma_zscore,0,MODE_SMA,i) / iStdDevOnArray(diff,0,ma_zscore,0,MODE_SMA,i);
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


Hello everyone, I am new to programming with mql4, and I want to program an indicator that shows me the z-score of the differential between two instruments, in this case I enclose all the code I have for the differential between AUDUSD and NZDUSD with the image where the error about "zero divide in" appears.

 
  1.    double diff[1];
    
    Diff has only one element. What do you expect happens when i becomes one? You would know that if you had used strict.

    Always use strict. Fixing the warnings will save you hours of debugging.

  2. iClose(symbol1,1440,i)
    Don't hard code numbers, use the appropriate enumeration.
  3. iMAOnArray(diff,0,ma_zscore,0,MODE_SMA,i)
    ma_zscore has no values. What do you expect?

  4. iMAOnArray requires your array to be filled out (but you are counting up) and you need to set as-series before filling.
Reason: