Duplicate orders when TWS lose connection

Questions about MultiCharts and user contributed studies.
palmone
Posts: 34
Joined: 24 Apr 2014
Has thanked: 4 times
Been thanked: 2 times

Duplicate orders when TWS lose connection

Postby palmone » 21 Aug 2014

Working in AA mode (the only possible way to trade with multistrategy in the same underlying) when tws lose his connection for any reason for some seconds ( i'm not meaning the auto-logoff tws that occurs 1 time a day and when you have to relogon manually) , and after that automatically reconnect, AA strategy send new orders even if the previous one was not cancelled.
For a pratical example:
I have a position in e-mini dj with a stop loss order, during the night tws lose connection and reconnected automatically after few seconds, MC(that remained open) send another stop loss order even if the previous one is still active.
The results is a double stop loss order duplicated.
There is a way to prevent this problem? MC can't recognize the previos order? is there a programming solution for that (in strategy code i mean).

Another problem is that working in SA, if you turn off for a second SA automate order execution and you have a open position, if you turn on again there is no way to alligne MC with broker: you still have a position in the account but for MC you are flat.
Thank you very much for your work and have a nice day!

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Duplicate orders when TWS lose connection

Postby Henry MultiСharts » 21 Aug 2014

Working in AA mode (the only possible way to trade with multistrategy in the same underlying) when tws lose his connection for any reason for some seconds ( i'm not meaning the auto-logoff tws that occurs 1 time a day and when you have to relogon manually) , and after that automatically reconnect, AA strategy send new orders even if the previous one was not cancelled.
For a pratical example:
I have a position in e-mini dj with a stop loss order, during the night tws lose connection and reconnected automatically after few seconds, MC(that remained open) send another stop loss order even if the previous one is still active.
The results is a double stop loss order duplicated.
There is a way to prevent this problem? MC can't recognize the previos order? is there a programming solution for that (in strategy code i mean).
Hello palmone,

Similar question has been already raised multiple times. Please see my replies in the related topics:1, 2.
Another problem is that working in SA, if you turn off for a second SA automate order execution and you have a open position, if you turn on again there is no way to alligne MC with broker: you still have a position in the account but for MC you are flat.
Thank you very much for your work and have a nice day!
When auto trading is turned off - the strategy position becomes zero. If you have an open position at the broker and you want your strategy to continue trading this position - you need to specify the position manually for each strategy next time you turn on the auto trading.
Please do the following:
Go to Format-> Strategy properties-> Auto trading-> Assign the initial market position at the broker setting->Show the assign the initial market position at the broker dialogue-> Show always-> Ok.

When you start the auto trading - a dialogue window will appear where you can set the position for the strategy. This is how you can synchronize your broker and strategy positions.

You can also synchronize your strategy and broker position automatically with the help of the synchronizer script (!From Broker To Strategy MP Synchronizer!). Position at the broker cannot be divided between multiple strategies automatically by means of the "synchronizer" script. If you are trading with multiple strategies on one instrument - you need to assign the position manually for each strategy. For more information on the synchronizer script usage please refer to the following pages: #1 and #2.

User avatar
Smoky
Posts: 517
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 99 times
Been thanked: 121 times

Re: Duplicate orders when TWS lose connection

Postby Smoky » 21 Aug 2014

hi Henry,

Sorry i'm not agree with you, MC 9 have a reconnection issue, as I have already explain, in reconnection buffered order are sent to the broker !

Here a example wirh HAC buy order and P1 pyramid orders, pyramid order are sent on reconnection !

Image

As I already ask, we need powerlangage new functions to manage reconnection :
- erase buffered orders on reconnection, (better in disconnection LoL )
- manage backfill data or not.
- manage status broker disconnection AND datafeed disconnection

Thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Duplicate orders when TWS lose connection

Postby Henry MultiСharts » 21 Aug 2014

Smoky, did you read the reply in the links I have provided? I will quote it here again:
IB support has studied the case and provided recommendations on improving MultiCharts to IB API connection that should resolve the issue.
As significant changes in the connection algorithms are required – these improvements have been targeted to the next major platform revision which is MultiCharts 9.1 Beta 1. There is no ETA for this version at the moment.


Return to “MultiCharts”