How to Set optimization time frames just 2 TimeFrames : M1 and M5 Or Convert int to TimeFrame

 
Hi All.
I am using this code
input ENUM_TIMEFRAMES TF = PERIOD_M1;

in optimization by genetic I need to use just 2 timeframes:

M1   and    M5
How to set it?


One way is to use this code:

input TF = 1;

AND then in genetic tester optimization use for TF :


                 start   =  1   >>   Step =4   >>   Stop = 5

BUT:

the indicator  gives ERROR :

   int header = iMA(_Symbol , TF , 0 , 0 , MODE_SMA , PRICE_CLOSE);

'TF' - cannot convert enum

because it is not Timeframe.

/////////////////

The solution is :

  ENUM_TIMEFRAMES TimeFrame;
  if(TF == 1)TimeFrame = PERIOD_M1;
  if(TF == 5)TimeFrame = PERIOD_M5;
  int header = iMA(_Symbol , TimeFrame , 0 , 0 , MODE_SMA , PRICE_CLOSE);


But,  I don't want to use ""int""   or if I had to use int I don't use so many IF's  ( Maybe I use more time frames for optimization).

And , I don't want to use ""FUNCTION"" return the TimeFrame.

I know   """declaring an enum """   could solve it.

But How? ..
This Code Does'nt work also:

enum MyTF
  {
    M1 = PERIOD_M1,
    M5 = PERIOD_M5
  };
input MyTF     TF = M1;

Thanks for help in advance.

 
J-C:
Hi All.
I am using this code

in optimization by genetic I need to use just 2 timeframes:

M1   and    M5
How to set it?


One way is to use this code:

AND then in genetic tester optimization use for TF :


                 start   =  1   >>   Step =4   >>   Stop = 5

BUT:

the indicator  gives ERROR :

'TF' - cannot convert enum

because it is not Timeframe.

/////////////////

The solution is :


But,  I don't want to use ""int""   or if I had to use int I don't use so many IF's  ( Maybe I use more time frames for optimization).

And , I don't want to use ""FUNCTION"" return the TimeFrame.

I know   """declaring an enum """   could solve it.

But How? ..
This Code Does'nt work also:


Thanks for help in advance.

Try to open moving average with "iCustom" it works for me... and you can use this with out problems.
input ENUM_TIMEFRAMES TF = PERIOD_M1;
it is just an idea...
 
J-C:
Hi All.
I am using this code

in optimization by genetic I need to use just 2 timeframes:

M1   and    M5
How to set it?


One way is to use this code:

AND then in genetic tester optimization use for TF :


                 start   =  1   >>   Step =4   >>   Stop = 5

BUT:

the indicator  gives ERROR :

'TF' - cannot convert enum

because it is not Timeframe.

/////////////////

The solution is :


But,  I don't want to use ""int""   or if I had to use int I don't use so many IF's  ( Maybe I use more time frames for optimization).

And , I don't want to use ""FUNCTION"" return the TimeFrame.

I know   """declaring an enum """   could solve it.

But How? ..
This Code Does'nt work also:


Thanks for help in advance.

I'm not familiar with genetic algorithms, but you might be able to use an array for timeframes.

 
J-C: But How? ..

This Code Does'nt work also:

enum MyTF
  {
    M1 = PERIOD_M1,
    M5 = PERIOD_M5
  };
input MyTF     TF = M1;

That is exactly how to do it. Then in the iCustom call cast it to a ENUM_TIMEFRAMES

 
William Roeder #:

That is exactly how to do it. Then in the iCustom call cast it to a ENUM_TIMEFRAMES

Good.Thanks
 
I know this is an old thread. Just leaving this here for anyone who is still confused about how to cast it:

enum MyTF
  {
    M1 = PERIOD_M1,
    M5 = PERIOD_M5
  };

input MyTF TF = M1;

//---

Handle = iCustom(NULL,(ENUM_TIMEFRAMES)TF,name);


Reason: