How to remove "Current" from ENUME_TIMEFRAMES

To add comments, please log in or register
Reza nasimi
373
Reza nasimi  
I'd like to use ENUM_TIMEFRAMES But removing the Period Current.


Is there a way to use defult ENUMs but lock(remove) one or a few of values in input parameters?

I hope you got what I want to say but I give you an example

I want to make Time frames selectable in parameters window.

But I don't want it to show the  Current .


I know that I can make my own enum. No problem with that. so that's not a problem, i'm just curious to know.
I just wanted to know if it is possible  to use defult ENUM_TIMEFRAMES  but removing one or more values.

Regards

Marco vd Heijden
Moderator
12393
Marco vd Heijden  
No but you can roll your own enum.
Reza nasimi
373
Reza nasimi  
Marco vd Heijden:
No but you can roll your own enum.

Thanks Marco vd Heijden
Nice to see you again after a long time

parham.trader
656
parham.trader  
Reza nasimi:
I'd like to use ENUM_TIMEFRAMES But removing the Period Current.


Is there a way to use defult ENUMs but lock(remove) one or a few of values in input parameters?

I hope you got what I want to say but I give you an example

I want to make Time frames selectable in parameters window.

But I don't want it to show the  Current .


I know that I can make my own enum. No problem with that. so that's not a problem, i'm just curious to know.
I just wanted to know if it is possible  to use defult ENUM_TIMEFRAMES  but removing one or more values.

Regards

You can do so by creating a synthetic ENUM_timeframes as shown below:

enum ENUM_Timeframe
  {
   Any_timeframe=-1,
   M1=1,
   M5=5,
   M15=15,
   M30=30,
   H1=60,
   H4=240,
   D1=1440,
   W1=10080,
   MN=43200,
  };

then for selecting the preferred timeframe you should use the code below:

extern ENUM_Timeframe selected_Timeframe=Any_timeframe;//Selected Timeframe

Be noted that from thereafter you have to use the above mentioned variable as the timeframes in your code.

Hope it helps.

Anthony Garot
3217
Anthony Garot  
parham.trader:

then for selecting the preferred timeframe you should use the code below:

That would work, but you wouldn't have to hard code the numerical values. You can do something like this:

enum EnAcceptableTimeFrames
{
    _PERIOD_H4 = PERIOD_H4,
    _PERIOD_D1 = PERIOD_D1,
    _PERIOD_W1 = PERIOD_W1,
    _PERIOD_MN1 = PERIOD_MN1
};
parham.trader
656
parham.trader  
Anthony Garot:

That would work, but you wouldn't have to hard code the numerical values. You can do something like this:

I admire your advice and confirm that it would be more suitable to code like what you mentioned.

Reza nasimi
373
Reza nasimi  
parham.trader:

You can do so by creating a synthetic ENUM_timeframes as shown below:

then for selecting the preferred timeframe you should use the code below:

Be noted that from thereafter you have to use the above mentioned variable as the timeframes in your code.

Hope it helps.

Thanks  parham.trader

I appreciate your help, 
As I mentioned before, The question was to see if there is a way to not write a new enum.

But Thanks for your time.

To add comments, please log in or register