Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1119
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Because minute timeframes below H1 return the correct values.
As described in the help, they return timeframe value, not an out-of-the-box constant.
What nonsense?
Wipe your eyes, I showed you the internal representation of ENUM_TIMEFRAMES
bit 16 which is set determines the weekly and monthly timeframe
bit 15 set defines the hourly time TF, where TF D1 = 1000000011000 --> 11000 --> 24, i.e. the developers have compared D1 to 24 hours and the remaining hourly time TFs correspond to the decimal conversion
the minute timeframes are the same as the hour ones, but the high bits are reset
another issue is that you thought the functions returning ENUM_TIMEFRAMES return the time of the TF in minutes - this is not true, these functions return the ENUM_TIMEFRAMES enumeration - no more or less, just ENUM_TIMEFRAMES
see the example from the helpat https://www.mql5.com/ru/docs/basis/types/integer/enumeration.
enums can also be with assignment of any constant value to a member of the enum
You can create your own enumeration to suit your needs
https://www.mql5.com/ru/articles/18
https://www.mql5.com/ru/articles/5798
Thank you so much! It waswchar_t that helped! I read about it, it stores 2 bytes per character, unlike char.
But the "str" function parameter still doesn't return the value assigned to it... I wonder why...
Hello, could you tell me how to solve a problem? I want to write an EA based on an indicator (tied to the iron) that builds a lot of levels (lines) on the chart, the number of lines can reach 500.
All I want to implement is to open an order or any other event (like alert or message) when price crosses lines on the chart. But the problem is that the indicator does not return any values and only draws horizontal lines (objects with names) - there is nothing else on the chart.
I tried to find a solution through the iCustom function that retrieves price levels via the "_price" variable, but the EA does not open trades when lines are touched. I do not know what I have done wrong.
OPTION 2. An order is opened on the line I have specified in the settings, it works and opens trades at the level I have specified in the EA parameters
Hello, could you tell me how to solve a problem? I want to write an EA based on an indicator (tied to the iron) that builds a lot of levels (lines) on the chart, the number of lines can reach 500.
All I want to implement is to open an order or any other event (like alert or message) when price crosses lines on the chart. But the problem is that the indicator does not return any values and only draws horizontal lines (objects with names) - there is nothing else on the chart.
I tried to find a solution through the iCustom function that retrieves price levels via the "_price" variable, but the EA does not open trades when lines are touched. I do not know what I have done wrong.
OPTION 2, an order is opened at the line I have specified in the settings; it works and opens trades at that level, which I have specified in the EA parameters
BUT, what if the Bid for some reason jumped the line, and was not equal to the price of the line, then what? Provide then at least a variable that stores the previous tick, and if it was a new tick crossed your line - then do some action ... But in this case do not forget to provide "permissible" crossing, because if the market opens with a large Gap, or there is a large jump in price, you will open on many lines in one go and probably not on the place you want. If the crossing is bigger than allowed - only a message will be given...
BUT, what if the Bid for some reason crossed the line, and was not equal to the line price, then what...? Provide then at least a variable, in which previous tick is stored, and if there was a new tick crossing your line - then do some action... But in this case do not forget to provide "permissible" crossing, because if the market will open with a Gap large, or just a big jump in price, you will open on many lines in one go and probably not there where you want. If the crossing is bigger than allowed - only a message will be given...
Problem code.
What nonsense?
Wipe your eyes, I showed you the internal representation of ENUM_TIMEFRAMES
bit 16 which is set determines the weekly and monthly timeframe
bit 15 is set to determine the hourly time TF and TF D1 = 1000000011000 --> 11000 --> 24, i.e. the developers have compared D1 to 24 hours and the remaining hourly time TFs correspond to the decimal conversion
the minute timeframes are the same as the hour ones, but the high bits are reset
another issue is that you thought the functions returning ENUM_TIMEFRAMES return the time of the TF in minutes - this is not true, these functions return the ENUM_TIMEFRAMES enumeration - no more or less, just ENUM_TIMEFRAMES
see the example from the helpat https://www.mql5.com/ru/docs/basis/types/integer/enumeration.
enums can also be with assignment of any constant value to a member of the enum
You can create your own enumeration to suit your needs
Igor, it's been clear for a long time about constant values.
That's what I'm talking about, what is the meaning of 15 and 16 bits as a return value. This is just nonsense.
For some reason before M30 ENUM constants corresponded toTIMFRAME values!!!!.
And further it already corresponds to values of some bits. Where the hell is the logic in guys.
This is a crude error. If it was done so intentionally, it's a diversion.)
Variable _Period already contains all these timeframe values from enumeration ENUM, they don't need additional conversion.
Therefore, these constant values, should correspond to timeframe values as stated in the help. Not BITS!
It's definitely time for quarantine. Search for everything that has been said about it and read it at your leisure. Why do you think people around you have to repeat everything you've written?
It's definitely time to quarantine it. Search everything that was said about it and read it at your leisure. Why do you think that people around you should repeat everything you have written?
And why do you put up with the wrong solutions? I have delivered a logical explanation of the values of the constants, not what the developer made up.
And why do you put up with the wrong solutions? I have delivered a logical explanation of the values of the constants, not what the developer made up.
Apparently for you there are only two opinions: yours and the wrong one. You may be able to find an explanation that suits you.
Try to use the value returned by _Period variable for periods higher than H1 in your mathematical calculations.
And you will immediately understand who is wrong.