Using presets for different TFs

 

To keep things simple and rather than having to change some of my EA settings each time i change time frame, I was thinking of setting up some presets that automatically applied based on the  _Period value. I don't know if i have taken the correct approach but i went down the path of multi dimensional array:

double settings[6]
double presets[5][6]

// Initialise multidimension array
double presets[5][6] = { 
         22,5,4,10,3,0.25,      // M5 	Index 0
         6,33,13,11,11,0.02,    // M15	Index 1
         6,21,10,4,6,0.25,      // M30	Index 2
         5,33,15,6,3,0.25,      // H1  	Index 3
         5,21,20,12,6,0.4,      // H2   Index 4
};

Where I am falling over is copying a row from a 2D array into the 1D array. From my reading in the guide regarding ArrayCopy, I thought I could do this via something like:

if (_Period == PERIOD_M15)
{
        ArrayCopy(settings, presets,0,1,WHOLE_ARRAY);
}

But I get a the following error:

 incompatible 2 arrays ranges for ArrayCopy function (0 and 1)

Maybe it's my Python bias coming through but what am I doing wrong here?

 
Noggy: Where I am falling over is copying a row from a 2D array into the 1D array.
  1. Do it yourself.
    enum preRows{ PR_M5, PR_M15, PR_M30, PR_H1, PR_H2};
    double presets[5][6] = { 
             22,5,4,10,3,0.25,      // M5   Index 0
             6,33,13,11,11,0.02,    // M15  Index 1
             6,21,10,4,6,0.25,      // M30  Index 2
             5,33,15,6,3,0.25,      // H1   Index 3
             5,21,20,12,6,0.4,      // H2   Index 4
    };
    
    if (_Period == PERIOD_M15)
    {
      for(int i=0; i <= 6; ++i) settings[i] = presets[PR_M15][i];
    }

  2. Or don't do it at all:
    #define settings(i) presets[iRow][i]
    int iRow;
    ⋮
      if (_Period == PERIOD_M15) iRow=PR_M15;
    

 

Thanks, I was thinking that there may have been a simpler way than method 1 to do it.

Apologies for my lack of understanding, but I don't quite get method 2?

Reason: