简体   繁体   中英

Array function use on strict mode

i have trouble for using these array function to be able to use it on MQL4 strict mode. Could anyone hint me where i should start? The purpose is so it could work on strict mode.

int Trigger;

 void function6(int &arrays[50])
  {
   int vals = ArraySize(arrays);
   int trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
   while(trailingstop > Trigger)
     {
      arrays[function5(arrays) - 1] = 0;
      trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
      if(function5(arrays) < 2)
         break;
     }
  }
                                        
int function5(int &arrays[50])
  {
   int vals = ArraySize(arrays);
   for(int k = 0; k < vals; k++)
      if(!(arrays[k] > 0))
         return (k);

   return (vals - 1);
  }

void function4(double &val[50])
  {
   int vald = ArraySize(val);
   for(int l = vald; l > 0; l--)
      val[l] = val[l - 1];
   val[0] = 0;
  }

void function3(int &arrays[50])
  {
   int vald = ArraySize(arrays);
   for(int l = vald; l > 0; l--)
      arrays[l] = arrays[l - 1];
   arrays[0] = 0;
  }

Arrays start at 0, not 1. When using ArraySize to define counting of arrays, you should always minus 1 to account for starting at 0.

void function6(int &arrays[50])
{
   int vals = ArraySize(arrays)-1;
   int trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
   while(trailingstop > Trigger)
   {
      arrays[function5(arrays) - 1] = 0;
      trailingstop = TimeCurrent() - (arrays[function5(arrays) - 1]);
      if(function5(arrays) < 2) break;
   }
}

int function5(int &arrays[50])
{
   int vals = ArraySize(arrays)-1;
   for(int k = 0; k < vals; k++)
   if(!(arrays[k] > 0)) return (k);
   return (vals - 1);
}

void function4(double &val[50])
{
   int vald = ArraySize(val)-1;
   for(int l = vald; l > 0; l--)
   val[l] = val[l - 1];
   val[0] = 0;
}

void function3(int &arrays[50])
{
   int vald = ArraySize(arrays)-1;
   for(int l = vald; l > 0; l--) arrays[l] = arrays[l - 1];
   arrays[0] = 0;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM