Inflight cancellation of submitted order on simulator: Is this accurate?  [SOLVED]

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Inflight cancellation of submitted order on simulator: Is this accurate?

Postby wilkinsw » 23 May 2018

Hi,

I wanted to ask MC if certain behaviour when auto trading on Paper Trader is accurate.

If you run the following code:

Code: Select all

[intrabarordergeneration=true];
recalclastbarafter(.01);

if getappinfo(aiCalcReason)=0 then
buy ("test")next bar at close+10 limit {or market};

sell from entry ("test") next bar at market;

once cleardebug;
if lastbaronchart then begin
print(time:0:0, " , ", BarStatus(1) = 2, " , ",getappinfo(aicalcreason),marketposition);
end;
You will see orders get submitted but then immediately cancelled. For me most get cancelled and few get filled. The submitted orders are marketable. Please note that the above code was put together purely to demonstrate this behaviour.

I'm wondering if this is inaccurate behaviour and just a quirk of the Paper Trader sim?

If one uses market orders instead then all orders appear to get filled.

So why are we seeing a high number of "inflight" order cancellations just for limit orders (even though they are marketable)?

Reason I'm asking; I want to build IOG signals with script that only runs on very discreet events as to be efficient as possible. With MC's current architecture; once an order is submitted, if it's marketable, then is there any way for MC to cancel it inflight?

Sounds like a crazy question, but I'm wondering if in the event of an order batch queue, can MC cancel an order that was already submitted (but is still technically queued and not really submitted)?

I'm hoping the above is indeed just a simulator quirk else I'll be forced to build much slower IOG signals.

Thanks!

wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby wilkinsw » 24 May 2018

Also, is there any difference, when live trading, in the speed that MC is able to send a market order vs a limit?

I'm performing stress tests; running lots of IOG signals on the Paper Trader. I'm noticing that marketable limit orders are far more prone to triggering order batch queues than market orders.

Is there a reason for this?

User avatar
Anna MultiCharts
Posts: 461
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 113 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby Anna MultiCharts » 31 May 2018

Hello, wilkinsw!

Your code works as it’s written. If the conditions for a price order are not met on the next strategy calculation then the order is cancelled.
There’s no difference in the speed that MultiCharts is able to send a market or price orders. If you use any kind of order modification for price orders then each change is handled within the communication delay that is specified in the Paper Trader broker profile execution settings. If the delay time is higher than 100 ms then the batches of orders can be easily created. We recommend to set this parameter to average communication delay value with brokers which is ≈ 10-50 ms.

wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby wilkinsw » 31 May 2018

my opinion is that if an order is submitted then it's inflight.

it should not be possible to cancel an inflight order.

if on a certain tick buy=true then that order needs to be sent and not intercepted and cancelled in the event that a later tick buy=false and the order is stuck in a batch queue.

for some reason "market" orders don't seem to get cancelled whereas "marketable limit" frequently do when there is a queue.

if buy=true then that explicit instruction needs to reach the broker/exchange. a slowdown in multicharts should not impact that central paradigm.

User avatar
Anna MultiCharts
Posts: 461
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 113 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby Anna MultiCharts » 01 Jun 2018

wilkinsw,

Each order has a life-span that is the time between the nearest strategy calculations.
A strategy can be calculated either on the bar close or on each tick in IOG mode. If the order triggering conditions are met on the next calculation then the order’s life is preserved on the broker. If the order triggering conditions are not met on the next calculation then the order gets cancelled. This is how order generation/cancellation works in autotrading in MultiCharts.

wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby wilkinsw » 01 Jun 2018

Forget about the broker. If I've sent the broker a marketable order and I'm not filled then I would come down like a ton of bricks on the broker.

This is a different issue I'm describing. Please take the time to review it and help me.

Before the order leaves Multicharts is it possible to intervene and cancel an order that is stuck in the queue (an order that was generated on an older tick)?

I'm asking if a slowdown in Multicharts can lead to an order that should've been sent to the broker never reaching the broker.

In my above code, using paper trader, it looks like that it is what I have demonstrated.

I'm trying to rule out if I've uncovered a bug or not. Please advise.

User avatar
Anna MultiCharts
Posts: 461
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 113 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby Anna MultiCharts » 06 Jun 2018

wilkinsw,

“Before the order leaves Multicharts is it possible to intervene and cancel an order that is stuck in the queue (an order that was generated on an older tick)?” – if an order was generated by a strategy and it complied with the rules of PowerLanguage then it will be sent in any case even if it gets stuck in the order queue for half an hour. I’m afraid there’s no way to remove an order from this queue.

wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?

Postby wilkinsw » 06 Jun 2018

Thanks Anna!

That's not what I found in the paper trader. If prevailing price was 100 and on a tick I sent buy at 110 limit order (with a communication delay set at 0.2-1 second):

You would often see order submitted...then cancelled a second or so later with no fill.

I'm going to deploy an IOG algo live now that uses marketable limit orders and report back if I'm seeing inflight cancelled orders.

wilkinsw
Posts: 557
Joined: 21 Apr 2013
Has thanked: 138 times
Been thanked: 91 times

Re: Inflight cancellation of submitted order on simulator: Is this accurate?  [SOLVED]

Postby wilkinsw » 08 Jun 2018

In live trading:

so far I'm seeing correct behaviour.

About 0.1s after i sent my marketable limit order, MC tries to cancel it (on a subsequent tick where buy=false). But that's not an issue as I'm filled.

Might I suggest MC tweaks paper trader behaviour so that a submitted marketable order can't be cancelled, as this is not real world behaviour.

I'll report with findings when markets get busier as it will be interesting to see the effect of slowdowns on this behaviour.


Return to “MultiCharts”