Questions from Beginners MQL5 MT5 MetaTrader 5 - page 602
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
In an indicator or in an EA/script?
Yuri Evseenkov:
fromme2you:
Another question: how to stress the developer of MT4 and MQL code execution environment, so that he(they) put mind and hand in developing a language to handle exceptions, such as in my example or similar in meaning?
Contact servesdesk, create a thread/survey on the forum.
It wasn't so long ago that MT4 was buried. They do not have a clear view on the market, they have a clear view on the regulation of the market.
See Renat's post today:
...
MT4 development is stopped and there will be only fixes and cosmetics.
Hello. Can you please advise how to solve this issue. I need to find the open prices of bars at a certain time, for example at 01:00, by analyzing for example the last 50 bars. I'm not sure how to go about this task in mql5.
Whether by calculating the current date + adding the required time to it and then adding twenty-four hours, this method worked on mql4.
As far as I understood mql5 has special structures with time output, but for some reason I can't use them.
Thanks in advance for the answer.
I would be very grateful if somebody could throw me a bit of code to understand the thinking process.In the indicator.
Here, for better understanding, I advise to first look at the numbering of bars. First we need to understand exactly how the rightmost bar in the MQL5 indicator is numbered.
To do this, put the following comment in the indicator in OnCalculate:
This code will produce this result:
That is, by default the rightmost bar in MQL5 indicator arrays has an index equal to "rates_total-1".
Returning to your question - you need to take the last 50 bars and pass through them. And analyze the open time of the bar (the time[] array), if the bar time is equal to the specified one, remember the index of the bar. Then obtain the open price from the open[] array using this index.
It looks similar to this:
Here, in order for you to better understand later, I advise you to start by looking at the numbering of bars. That is, you should first understand exactly how the rightmost bar in MQL5 indicator is numbered.
To do this, put the following comment in the indicator in OnCalculate:
This code will produce this result:
That is, by default the rightmost bar in MQL5 indicator arrays has an index equal to "rates_total-1".
Returning to your question - you need to take the last 50 bars and pass through them. And analyze the open time of the bar (the time[] array), if the bar time is equal to the specified one, remember the index of the bar. Then retrieve the open price from the open[] array.
It looks approximately like this
Karputov Vladimir, thank you very much. I really appreciate it. I think mql5 has more flexible access to timeseries, but it's a bit complicated for "newbie" programmers. :))
It's a matter of habit. Then you will find that everything is structured, easy and correct.
Another question. The parameters
I think they are responsible for the pair the indicator is applied to. So, it's impossible to obtain the same information about another currency pair? In other words, the more universal solution is to create the same arrays of OCHL only through Copy function...?Another question. Parameters
I understand that they are responsible for the pair to which the indicator is applied. And to pull out with their help the same information about another currency pair is impossible? So, the more universal solution is to create the same arrays OCHL only through Copy function...?When accessing other people's characters, there are nuances that you need to understand and be aware of:Organising data access. In other words, if you request someone else's symbol timeseries data - you must first make sure that this data has been prepared and exists. Only this way you can be sure that the data you request from the alien character is correct.
Got it. Thank you.
Another question does you always convert values into the string type in the Print() function. What is the purpose of doing this? Without translation, the int, double, etc. types are displayed in the Print() function in exactly the same way.
Got it. Thank you.
Another question do you always convert values to the string type in the Print() function. What is the purpose of doing this? Without translation, the int, double, etc. types are displayed in Print() in exactly the same way.
The way a number is stored in computer memory and the way it is output are two big differences. Especially with floating point numbers, it's always better to limit the number of decimal places.
That's why I always try to format the output correctly - useIntegerToString andDoubleToString.
The way a number is stored in computer memory and the way it is output are two big differences. Especially with floating point numbers, it's always better to limit the number of decimal places.
That's why I always try to properly format number output usingIntegerToString andDoubleToString.
Thank you for your answers and patience.
Vladimir, I am probably tired of you :) But the progress in the basics is going very slow. I tried to do a test task with Copy function... The indicator isn't drawn, though there are numbers in Printe... I don't understand anything.