Features of the mql5 language, subtleties and tricks - page 5

 
Dmitry Fedoseev:

It would be better to write a separate function for waiting, so that the standard trading class could be used as well.

If you insert solution before SB now, it becomes synchronized.

Forum on trading, automated trading systems and strategy testing

Features of mql5 language, subtleties and tricks

fxsaber, 2017.02.25 16:02

If you want to make all OrderSend synchronized with the trading environment and avoid the pitfalls, it is sufficient to make this source code as an mqh-file and do the corresponding #include in your programs.

 
Dmitry Fedoseev:

Things are much easier. Before sending the order, I memorized the length of the history, and after sending it, I waited for the history length to increase. A timeout should be entered, so that suddenly it would not be stuck forever.

fxsaber:

There is a timeout. In your version, unfortunately, there may be problems if several OrderSends work together (from different Expert Advisors).

Doesn't ORDER_MAGIC help in this situation? Just to check the history of your EA?
 
Vasiliy Pushkaryov:
Would ORDER_MAGIC help in this situation? Just to check the history of your EA?
It will help
 
Vasiliy Pushkaryov:
Wouldn't ORDER_MAGIC help in this situation? Just to check the history of my Expert Advisor?
There could be a problem with that.

Forum on trading, automated trading systems and trading strategies testing

Features of mql5 language, tips and tricks

fxsaber, 2017.02.25 17:29

Also, not only history is not synchronized, but also SL/TP of open positions/orders, etc.

For marques, the history can only increase by an order at first, and then a moment later by a trade.

In addition, ORDER_MAGIC is already a history request. In other words, you can't just wait for the history to increase, as was suggested earlier.

I don't quite understand why we have to think up any methods when only one of them can work (as a wait), based on the logic of waiting.

For every TRADE_ACTION you have to wait for something specific. That's just the specific one to wait for. There is no sense in waiting for something else. There is no second solution at all.

 
fxsaber:
There may be a problem with it.

Besides, ORDER_MAGIC is already a history request. In other words, you can't just wait for history to increase, as was suggested earlier.

It's not clear why we have to think up all sorts of ways, when only one of them can work (as a wait), based on the logic of what you have to wait for.

For every TRADE_ACTION you have to wait for something specific. That's just the specific one to wait for. There is no sense in waiting for something else. There is no second solution at all.

You are such an interesting fellow. If you don't spell it out in detail, you won't get it. Waiting for the story to increase with the magician.
 
Dmitry Fedoseev:
Waiting for the story to increase, taking into account the magician.
And if you do?
 
fxsaber:
What if the modify?
Why wait after it?
 
Dmitry Fedoseev:
Why should I wait after it?
When modifying a pending order after a successful OrderSend, you may run into this
(ENUM_ORDER_STATE)::OrderGetInteger(ORDER_STATE) == ORDER_STATE_REQUEST_MODIFY

in addition to the fact that SL/TP are not immediately updated, as with position modification.

ZZY It is possible to find out nuances only in case of stress-tests of many trading servers. Without it, the real trade is a trick.

 
It's always something to get caught up in.
 
Dmitry Fedoseev:
It's always possible to run into something
The proposed solution has not run into anything else so far. That is why I could not offer a better one.