Download MetaTrader 5
To add comments, please log in or register
How to test a program before buying?
Winsor Hoang
4743
Winsor Hoang 2014.11.29 17:22 
Here is my current code:
            if (ArraySize(Close) > 101) 
               {
               ArrayCopy(ClosePriceArray, Close, 0, 1, 100);
               ArrayCopy(OpenPriceArray, Open, 0, 1, 100);
                }

 

How can I rewrite the code so that it will always address EURUSD, PERIOD_M15? I have tried the following code:

 

               ArrayCopyRates(double_array,"EURUSD",PERIOD_M15);
               ArrayCopy(ClosePriceArray, double_array[0][4],0,1,100);

 

I received the error message 'double_array" - array required.

 

BTW, how do I deal with  if (ArraySize(Close) > 101)? 

whroeder1
13641
whroeder1 2014.11.29 19:33  
waterhorse: I received the error message 'double_array" - array required.
ArrayCopyRates(double_array,"EURUSD",PERIOD_M15);
  1. Show all the relevant code, like your declarations. How should we know what double_array is, unless you show it?
  2. MqlRates chartM15[];
    init(){ ArrayCopyRates(chartM15,"EURUSD",PERIOD_M15); ...}
    start(){
       Print("EURUSD close[1]="+chartM15[1].close);
Winsor Hoang
4743
Winsor Hoang 2014.11.29 23:35  

WHRoeder,

Thanks for your reply:

 

Here is the declaration:

 

 

 

   double ClosePriceArray[];
   double OpenPriceArray[];

if (ArraySize(Close) > 101) 
               {
               ArrayCopy(ClosePriceArray, Close, 0, 1, 100);
               ArrayCopy(OpenPriceArray, Open, 0, 1, 100);
               RandVar = 0;
               if (doublecnt > 0.0) 
                  {
                  for (int cnt = 0; cnt < ArraySize(ClosePriceArray); cnt++) 
                     {
                     if (MathRand() > 383) RandVar = (MathRand() + 0.0001) / 767.0 * (doublecnt * Point);
                     else RandVar = (-(MathRand() + 0.0001)) / 767.0 * (doublecnt * Point);
                     ClosePriceArray[cnt] += RandVar;
                     }
                  for (cnt = 0; cnt < ArraySize(OpenPriceArray); cnt++) 
                     {
                     if (MathRand() > 383) RandVar = (MathRand() + 0.0001) / 767.0 * (doublecnt * Point);
                     else RandVar = (-(MathRand() + 0.0001)) / 767.0 * (doublecnt * Point);
                     OpenPriceArray[cnt] += RandVar;
                     }
                  }
               } 
Winsor Hoang
4743
Winsor Hoang 2014.11.30 21:19  

Is there a way that we can limit the size of the ArrayCopyrates? It takes a long time for the backtesting. 

 

ArrayCopyRates(double_array,"EURUSD",PERIOD_M15); 
/
To add comments, please log in or register