invalid array access in Output Function

 

i wrote a function to give a vector [ z1...z10] of zigzag index of any forex currency in function output.

but it show error in compliation.


// int ExtDepth=12;
   int bigshift=1;
   int ExtDeviation=5;
   int ExtBackstep=3;
   int counted_bars=IndicatorCounted();
   int izig=0,MaxZig=8;
   double Ext,ZigArray[];
   ArrayResize(ZigArray,MaxZig);

   if(counted_bars<0)
      counted_bars=0;
   if(counted_bars>0)
     {
      counted_bars--;
      while(izig<MaxZig)
        {
         Ext=iCustom(symbolName,ZTimeframe,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,bigshift);
         bigshift++;
         if(100000*Ext>1)
           {
            ZigArray[izig]=Ext;
            izig++;

           }
        }
     }
   return (ZigArray);

'ZigArray' - invalid array access Ztest.mq4  93 12



that   ZigArray is my required vector with 8 elements.

please help me to solve it.

god bless you

Documentation on MQL5: Language Basics / Variables
Documentation on MQL5: Language Basics / Variables
  • www.mql5.com
Variables - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
You can not return an array. Pass the array in by reference.
 
MatlabCoder98:

i wrote a function to give a vector [ z1...z10] of zigzag index of any forex currency in function output.

but it show error in compliation.


'ZigArray' - invalid array access Ztest.mq4  93 12



that   ZigArray is my required vector with 8 elements.

please help me to solve it.

god bless you

//  while(izig<MaxZig-1)

// int ExtDepth=12;
   int bigshift=1;
   int ExtDeviation=5;
   int ExtBackstep=3;
   int counted_bars=IndicatorCounted();
   int izig=0,MaxZig=8;
   double Ext,ZigArray[];
   ArrayResize(ZigArray,MaxZig);

   if(counted_bars<0)
      counted_bars=0;
   if(counted_bars>0)
     {
      counted_bars--;
      while(izig<MaxZig-1)
        {
         Ext=iCustom(symbolName,ZTimeframe,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,bigshift);
         bigshift++;
         if(100000*Ext>1)
           {
            ZigArray[izig]=Ext;
            izig++;

           }
        }
     }
   return (ZigArray);
This website uses cookies. Learn more about our Cookies Policy.