Questions from Beginners MQL5 MT5 MetaTrader 5 - page 984
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
But the fact of the matter is. Sleep should not affect the recalculation of data in the indicator. Something is wrong with buffer filling. Maybe there is a reproducible piece of code?The indicator was written to order - it's a wild OOP, I don't understand it :(
I spent all night with this problem, while I found the reason of divergence between tester and real account, maybe after sleeping I will remove some of secret logic and post it for review.
I faced a problem, the indicator based EA works correctly on a real account, but it is lying in the tester, in tick generation modes both by OHLC and by all ticks - the result is the same. The result of the error is the empty buffer of the indicator at zero bar (only when there is a new bar at the upper TF, which is used for the calculation of the indicator). However, I have managed to make indicator to be calculated by adding Sleep to my Expert Advisor. But I have found out that depending on the mode of ticks generation this Sleep should be different - for generation from all ticks Sleep(15000) is enough, while for OHLC Sleep(30000) is needed.
So the question arises - is the situation with Sleep normal, because it logically appears that different delay times are modeled there depending on the mode of tick generation!
Dear developers, please explain the situation with the indicator, because I myself do not understand what the reason is - a mistake in the code or in the tester!
I am ready to give you the indicator and the Expert Advisor in the PM, but tell me to whom.
If you want to copy the price to an array, you have to check if the history is available and check if the price is not changed. For this purpose, we have to check if the history for TF is available, if not, we should try to copy it again and wait until it has been loaded in the loop.
this is a bad hand of the programmer, if he did not know about it
slip is not normalPlease explain...
I press key = I get event id = 0. This can be repeated many times. The result is the same as long as the space bar is not pressed.
Pressed spacebar = I get event id = 0. After that all manipulations on the keyboard don't result in any event.
To get out of the stupor, I press the mouse button = I get event id = 4. After that you can click on the keyboard again = events come for every click. As long as no spacebar is pressed = with the same result.
Question: am I a fool not understanding something or it should not be like this? Please provide a link.
Hello colleagues.
Question: In mql4, in order to calculate the number of positions, you can write the function like this
How is it implemented in mql5? How can I calculate positions by magic number or by type?
Add this line before MQL4-function
and it will work in MT5.
The thing about indicators is that timeseries may not be ready yet, i.e. it cannot copy the price to an array at once. For this purpose, we should check if the history for TF is available, if not, we should try to copy it again and wait until it has been loaded in the loop.
This is a bad hand of the programmer if he/she does not know about it.
slip is not okHow is this possible in the tester? I understand if the problem is on the real or in the tester there is no history... However, what should this test look like?
Developers are ignoring my message, unfortunate.
How is this possible in the tester? I understand if the problem is on the real or in the tester there is no history there... However, what should this test look like?
Developers are ignoring my message, unfortunate.
check if prices are copied, if Copyclose or whatever returns -1 then they are not copied
check if prices are copied, if Copyclose or whatever returns -1 then they are not copied
The indicator is calculated once at appearance of a new bar, which is implemented, if I understand correctly, in this way:
it is also confirmed by a simple print.
That's why the situation is not clear, if we assume that there is no price to be calculated, the indicator will be calculated 1 time and the buffer will remain unfilled, but it's not so - it will fill if we add sleep to the EA and wait. Maybe, the indicator is slow in calculation and the tester just does not wait for it? But how to check it?
The indicator is calculated 1 time when a new bar appears, which is implemented, if I understand correctly, in this way:
this is also confirmed by a simple print.
That's why the situation is not clear, if we assume that there are no prices to be calculated, the indicator will be calculated once and the buffer will remain unfilled, but this is not the case - it will fill if we add sleep to the EA and wait. Maybe, the indicator is slow in calculation and the tester just does not wait for it? But how to check it?
Maybe it should be timed then
Maybe we should use a timer then.
Yes, with the timer in the EA the test goes a bit further than without the timer, but worse than with Sleep, and the timer is essentially the same as Sleep.
I think I understand what the problem is, the indicator is calculated using data of two other indicators and the code asks for the number of calculated bars of other indicators
and the expected calculated number of bars
If these two values don't coincide, the buffer is not filled.
If I understand correctly, the indicators are executed in one thread and their priority is distributed by the time of their creation, i.e. it turns out that the indicator I address from the EA has the higher priority and performs its calculation first and after that it passes the thread to those indicators which should perform the calculation (based on the buffers data).
In the print you can see that if I set Sleep of a sufficient size, the recalculation is performed in the indicator (I don't understand how yet) and why only after 13 seconds?
There is no timer in the indicator.
And what should I do to get correct calculation, trying to use while in EA before waiting for value in buffer doesn't help - hangs.