//time frame enumeration enum en_TF { M1, M5, M15, M30, H1 }; // converting the enum values to Time frame variables function ENUM_TIMEFRAMES ConvertTF(en_TF ptimeFrame) { switch(ptimeFrame) { case M1: return PERIOD_M1; case M5: return PERIOD_M5; case M15: return PERIOD_M15; case M30: return PERIOD_M30; case H1: return PERIOD_H1; default: return PERIOD_M15; } }It's similar to what you did but i code it in a function that takes in an enum variable as a parameter. It worked in my code feel free to give a try.
I have a dilemma, the thing is that I use the "Only Open Prices" modeling in the strategy tester and in the optimizer for more speed. The issue is that since I can only use temporalities that are non-multiple timeframes as it says in this section...
- In the tested Expert Advisor, you cannot access data of the timeframe lower than that used for testing/optimization. For example, if you run testing/optimization on the H1 period, you can access data of H2, H3, H4 etc., but not M30, M20, M10 etc. In addition, the higher timeframes that are accessed must be multiple of the testing timeframe. For example, if you run testing in M20, you cannot access data of M30, but it is possible to access H1. These limitations are connected with the impossibility to obtain data of lower or non-multiple timeframes out of the bars generated during testing/optimization.
- Limitations on accessing data of other timeframes also apply to other symbols whose data are used by the Expert Advisor. In this case the limitation for each symbol depends on the first timeframe accessed during testing/optimization. Suppose, during testing on EURUSD H1, an Expert Advisor accesses data of GBPUSD M20. In this case the Expert Advisor will be able to further use data of EURUSD H1, H2, etc., as well as GBPUSD M20, H1, H2 etc.
So, when I use different timeframes not allowed in the strategy tester or in the optimizer I get the error...but if I use the allowed temporalities if it works.
The problem comes when I optimize, it specifically uses the PERIOD_M12, so the tests give an error and the optimization ends in 1 minute due to the errors of the use of this temporality not allowed by "Only Open Prices".
so I've tried different ways to remove the PERIOD_M12 from my optimizations without success.
One of my attempts was to check if the periods used by the optimizer were all but PERIOD_M12 by using it in the OnInit() It works but as the "init" returns error several times the optimization ends without further ado., attached code:
Another attempt was to create my own enum_timeframes but without success....
Thank you for reading. I would like help on how to avoid optimization with PERIOD_M12.
It may not be what you want! But try OHLC 1min. It is fast and accurate.
- Saad Janah #: i use this format to filter out time frames:
Your code
simplified//time frame enumeration enum en_TF { M1 = PERIOD_M1, // 1 Minute M5 = PERIOD_M5, // 5 Minute M15 = PERIOD_M15, // 15 Minute M30 = PERIOD_M30, // 30 Minute H1 = PERIOD_H1 // 1 Hour }; // converting the enum values to Time frame variables function ENUM_TIMEFRAMES ConvertTF(en_TF ptimeFrame){ return ENUM_TIMEFRAMES(ptimeFrame); }
-
See also
Because the enumerations are not sequential, you can not increment/decrement them to get the next larger/smaller one.
Why are MT5 ENUM_TIMEFRAMES strange? - General - MQL5 programming forum - Page 2 #11 (2020)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a dilemma, the thing is that I use the "Only Open Prices" modeling in the strategy tester and in the optimizer for more speed. The issue is that since I can only use temporalities that are non-multiple timeframes as it says in this section...
So, when I use different timeframes not allowed in the strategy tester or in the optimizer I get the error...but if I use the allowed temporalities if it works.
The problem comes when I optimize, it specifically uses the PERIOD_M12, so the tests give an error and the optimization ends in 1 minute due to the errors of the use of this temporality not allowed by "Only Open Prices".
so I've tried different ways to remove the PERIOD_M12 from my optimizations without success.
One of my attempts was to check if the periods used by the optimizer were all but PERIOD_M12 by using it in the OnInit() It works but as the "init" returns error several times the optimization ends without further ado., attached code:
Another attempt was to create my own enum_timeframes but without success....
Thank you for reading. I would like help on how to avoid optimization with PERIOD_M12.