Features of the mql5 language, subtleties and tricks - page 97
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
It's kind of like there was already a solution in the KB:
But not for script. And it's rather difficult for EA, because it suggests to exit from OnTick in case of undefined situation. And this situation could happen somewhere deep in the guts of the EA. And not only we will have to get out of there, to get out of OnTick, but also there may be necessary to open, for example, two positions at once (a la cart). But in this case, the second one should be opened only if the first one was successfully opened. In this case, to get kicked out of OnTick after the first OrderSend, to put it mildly, is bad.
But not for the script. And it's hard enough for the Expert Advisor, because it suggests to kick out of OnTick in an undefined situation. And this situation could happen somewhere deep in the guts of Expert Advisor. And not only there will be necessary to get out of there, to get out of OnTick, so there may be necessary to open, for example, two positions at once (a la cart). But the second open only if the first successfully completed. In this case, to get kicked out of OnTick after the first OrderSend, to put it mildly, is not good.
The script can slow down to the explicit number of positions.
Expert Advisor... In the EA, we have to consider this in the logic of position opening functions - they are called from the EA with return of the result of their work. The result is returned to false when there is a market order. And then the EA will work according to its own logic. Yes, I agree that it is more difficult to implement in some ready-made EAs than to immediately consider this probability. But that's why the branch is here - to let others know and use the knowledge.
The script can be slowed down to explicitly get the number of positions.
You can also slow down the Expert Advisor.
The Expert Advisor... In the Expert Advisor, we will have to take into account the logic of the function of position opening - they are called from the EA with returning the result of their work. The result is returned to false when there is a market order. And then the EA will work according to its own logic. Yes, I agree that it is more difficult to implement in some ready-made EAs than to immediately consider this probability. But this is what the branch is for - to let other traders know and use the knowledge.
It is just necessary to wait a little bit until the moment when the deal has passed. Exiting the TS until the next tick is a terrible decision.
You can also slow down the Expert Advisor.
You just have to wait a little bit until the moment when the trade passes. Exiting the TS until the next tick is a terrible solution.
Well, in that code, just waiting for a specified time is done. But you can't wait for hours - it waits for some time for a given number of attempts to get a valid environment, then exits with the result. Otherwise, if you wait a long time, the trading environment can change a lot, and it will be too late to drink borjomi :)
Well, in that code, just waiting for a given time is done. But you can't wait for hours - it waits for some time for a given number of attempts to get a valid environment, then comes out with the result. Otherwise, if you wait a long time, the trading environment can change a lot, and it will be too late to drink borjomi :)
Yeah, I didn't notice the wait. That's fine. I was much more attentive then.
Imho, focusing onPositionsTotal() is the wrong decision in any case. During the processing of your request, another position could open/close on the account, for example, if several EAs work. What prevents you from checking the response from the server, as it is designed by the developers?
In fact, I do not see much sense in PositionsTotal, except for general control. The EA should clearly control the ticks of its positions and work only on them.
After using ChartIndicatorGet(), the IndicatorRelease(handle) function must necessarily be called. It is written about this in the example to the ChartIndicatorGet() function, but not in the remarks to the function! The developers wanted to correct the documentation, but didn't do it. Due to the closure of the SD, this will probably never be done.
I personally experienced the problem with the "hanging" indicator. From a conversation with the SD:
Ah, i.e., when I ran the X indicator on a chart, it looked through all indicators and detected a copy of it usingChartIndicatorGet()- it incremented the counter. I deleted the first indicator X - decrement of the counter, but I forgot about the second one and got a "hanging" indicator, because its handle wasn't cleaned?
Yes. That's exactly how it happens. Therefore, OnDeinit does not work.
Forum on trading, automated trading systems and testing trading strategies
How to import historical data into csv to symbol custom using CustomRatesUpdate?
fxsaber, 2018.08.19 12:01
The English part of the forum showed
what is the point? to save a couple of bytes of memory? especially with double you will get other numbers (== will be false) and integers can have an overflow