State of a partially filled cancelled order and how to force test situation
Hi guys,
I am finishing an EA and I am testing it. So far everything is ok, but there are some situations that I couldn't test and it really worries me.
For example: What is the ORDER_STATE of a partially filled order which has the pending part cancelled (IE. By order of 200 AAPL, 100 were executed, then 100 remaining were cancelled).
ORDER_STATE_PARTIAL, ORDER_STATE_CANCELED?
What brings me to the next question: Is there any way to force a situation in test?
Thanks.
Did you ever find a solution for this?
I also need to perform some testing with similar behavior.
Cheers!
The state of a partially filled order is ORDER_STATE_PARTIAL, as it has to inform the user about that fact that only a part of requested volume got filled.
What happens with the remaining volume depends on the filling policy (ENUM_ORDER_TYPE_FILLING) chosen in the initial order (whether you select IOC or Return).
Still, it is difficult (or even impossible) to test it in the backtesting or on demo account.
I would assume that:
- if filling type was "IOC", the order state changes to ORDER_STATE_PARTIAL and the order is moved to historical order database (as the unfllled volume gets canceled)
- if filling type was "Return", the order state changes to ORDER_STATE_PARTIAL and the order is still active - with the unfilled volume being stored in ORDER_VOLUME_CURRENT and the initial order volume in ORDER_VOLUME_INITIAL
Could anyone please confirm or deny?

- www.mql5.com
Still, it is difficult (or even impossible) to test it in the backtesting or on demo account.
You can create your own custom symbol and test it with different "filling mode" setting.
im also interested how to test ORDER_STATE_PARTIAL in tester.
There is no partial fill in tester, nor on demo.
I don't know about the order states, but do know what happens in practice. What can happen with limit orders ORDER_FILLING_RETURN, orders can be split.
Example you buy with limit order 1 lot EURUSD at current ask.
At that price only volume of 0.48 is available, you get filled 0.48.
This creates a buy position in the terminal with a volume of 0.48 and a buy limit order with a volume of 0.52 hanging till it gets filled the 1 lot initial order completely, or canceled.
If you encounter such an example depends on the exchange if any, and or broker.
It is however good practice to get your trade management logic to deal with these situations.

- www.mql5.com

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
I am finishing an EA and I am testing it. So far everything is ok, but there are some situations that I couldn't test and it really worries me.
For example: What is the ORDER_STATE of a partially filled order which has the pending part cancelled (IE. By order of 200 AAPL, 100 were executed, then 100 remaining were cancelled).
ORDER_STATE_PARTIAL, ORDER_STATE_CANCELED?
What brings me to the next question: Is there any way to force a situation in test?
Thanks.