Exit order is cancelling and resubmitting instead of modifying

Questions about MultiCharts and user contributed studies.
wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 26 Jul 2017

Hi,

I've uncovered that modifying an exit order size causes a cancel and re submission instead of a modify. Obviously that is not desired behaviour and does not happen for entry orders from what I can see.

Use the following code to demo:

Code: Select all

RecalcLastBarAfter(0.1);

[IntrabarOrderGeneration=true];

inputs: price(choose a price well above market);

if time>0 then buy ("b1") 1 shares next bar market;

if marketposition=1 then sell from entry ("b1") next bar at price limit;
Set "allow any entry from this strategy to occur [100] times per bar" under IOG settings.

What you'll see is that every time we buy 1 more to enter the exit gets cancelled and resubmitted with the new size.

It's not a big problem, but not ideal.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby Kristina MultiCharts » 26 Jul 2017

Hi,

Could you clarify what broker profile are you using for trading? If possible please send us MC logs from Feedback with 1 symbol being traded and the order being cancelled and resubmitted so we could check the case.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 26 Jul 2017

Paper Trader. TS data. Will do when I get a mo.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 26 Jul 2017

Have just sent it. In the example I've just sent it is a NON-IOG version and demos the stop being cancelled each bar.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby Kristina MultiCharts » 26 Jul 2017

Hi,

I'll get back to you with feedback as soon as the engineers check the logs.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 26 Jul 2017

Thanks Kristina.

I've just sent another feedback report that shows two orders being sent on the same bar, when live, despite settings prohibiting it (using Paper trader) and despite the backtest also only permitting one trade per bar. Would be good to know what's happened there. Very simple strategy with IOG off:

Code: Select all

inputs: price1(1247.0),price2(1290.0);


if time>0 then buy ("b1") 1 shares next bar at price1 limit;

if time>0 then buy ("b2") 1 shares next bar at price1 limit;

sell from entry ("b1") next bar at price2 limit;

sell from entry ("b2") next bar at price2 limit;
max is 1.PNG
(5.11 KiB) Downloaded 900 times

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 27 Jul 2017

The last issue (multiple entries when only one is permitted when backtesting) was fixed by turning ON optimize order flow.

I have that on for all my live trading...but didn't realise it was the reason why my strategies are only sending one signal at a time and why my backtesting is being correctly replicated . In fact optimize order flow seems obligatory if one has specified:
max is 1.PNG
(5.11 KiB) Downloaded 893 times
If you have specified...one order at a time (or any number of orders at a time) then optimize order flow MUST be ON to replicate backtesting behavior in realtime!

I didn't know that and thought it was worth sharing.

Might I insist that "optimize order flow" therefore be the default setting? Else MC will be catching some users out when they go live.

Thanks.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby Kristina MultiCharts » 27 Jul 2017

Hello,
Have just sent it. In the example I've just sent it is a NON-IOG version and demos the stop being cancelled each bar.
The engineers have checked the logs for this case and specified that everything worked as expected. Your price orders were cancelled because you have manually placed a market order. Market and Price orders cannot be sent in one group. When there are active price orders at the broker and you place market orders, price orders are cancelled in order to avoid reverse of position. This is true for all broker profiles including Paper Trader.

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby Kristina MultiCharts » 27 Jul 2017

Hello,
The last issue (multiple entries when only one is permitted when backtesting) was fixed by turning ON optimize order flow.

I have that on for all my live trading...but didn't realise it was the reason why my strategies are only sending one signal at a time and why my backtesting is being correctly replicated . In fact optimize order flow seems obligatory if one has specified:
max is 1.PNG

If you have specified...one order at a time (or any number of orders at a time) then optimize order flow MUST be ON to replicate backtesting behavior in realtime!

I didn't know that and thought it was worth sharing.

Might I insist that "optimize order flow" therefore be the default setting? Else MC will be catching some users out when they go live.

Thanks.
The option "Allow up to ... entry orders in the same direction as the currently held position..." doesn't affect the quantity of orders sent, it affects how many orders can be filled. In case 1 order is already filled and it's specified to allow 1 order in the same direction, the rest of the orders that were sent are cancelled.

"Optimize order flow" option should not be enabled by default as it is not necessary for all users and their setup. You can read more about how this option works here: https://www.multicharts.com/trading-sof ... Order_Flow

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 27 Jul 2017

Hi Kristina,
The engineers have checked the logs for this case and specified that everything worked as expected. Your price orders were cancelled because you have manually placed a market order. Market and Price orders cannot be sent in one group. When there are active price orders at the broker and you place market orders, price orders are cancelled in order to avoid reverse of position. This is true for all broker profiles including Paper Trader.
Not sure what's happened here. As no matter what order type I use or how I code the signal the following happens....

When the algo adds to the position (here using a same named entry) the attached exit order gets cancelled then resubmitted with the new size instead of simply being modified.

To the contrary, entry orders: If we modify the size on an entry order, on the fly (easily demoed by using "volume" as number of shares)...note how the order gets modified, not cancelled.

I'm gonna send you another feedback report that should demo it very very clearly indeed using this code:

Code: Select all

RecalcLastBarAfter(0.1);

[IntrabarOrderGeneration=true];

if time>0 then buy ("b1") 1 shares next bar at close+.5 limit;

if marketposition=1 then sell from entry ("b1") next bar at close+5 limit;
Settings: 1000 same named entries permitted per bar. IOG...permit 1000 entries per bar.

wilkinsw
Posts: 662
Joined: 21 Apr 2013
Has thanked: 154 times
Been thanked: 104 times

Re: Exit order is cancelling and resubmitting instead of modifying

Postby wilkinsw » 27 Jul 2017

The option "Allow up to ... entry orders in the same direction as the currently held position..." doesn't affect the quantity of orders sent, it affects how many orders can be filled. In case 1 order is already filled and it's specified to allow 1 order in the same direction, the rest of the orders that were sent are cancelled.

"Optimize order flow" option should not be enabled by default as it is not necessary for all users and their setup. You can read more about how this option works here: https://www.multicharts.com/trading-sof ... Order_Flow
You are 100% correct. With optimize order flow = OFF: If I send in all orders at the same time for all named entries.... when the first gets filled the others cancel, if only 1 entry is permitted.

But can you not see the issue here? The backtest environment assumes that only one entry can be sent at a time (not all of them!) with this setting on:
max is 1.PNG
(5.11 KiB) Downloaded 881 times
Let me put it another way.... Should I have 3 different named entries and by chance they have all calculated that they want to buy next bar at the same price.... Let's say that price is instantly marketable next bar:

a) How does the backtest engine handle that?
b) How does live trading handle that with the default "optimize order flow = OFF"?

Answer:

a) Long from 1 entry name
b) Long from ALL entry names (surprise!!!)

I may have missed an issue with defaulting to optimise order flow = ON. Else this is a slam dunk, job done, apply it to the next release job, no?


Return to “MultiCharts”