Hello, I am currently testing the conversion of some of my Autotrading via IB TWS from a thrid parts DLL Solution (TWSlink) to the Strategy Autotrading of MC. Some crucial points are not clear to me and I was unable to find the right answers here in this large forum....
When I have placed a strategy order via IB autotrading plugin and I have a TWS restart then the order cannot be handled by MC afterwards? Mapping is lost, is this right?
When I restart somehow MC all strategy position information is lost, as far as I know. Any idea how to save the information for the next session?
Rolling a futures position into the next expiry seems to be even more complicated i.m.o.
I am trading multiple strategies in different time compressions for the same instrument. Thus manual effort should be as minimal as possible. I am a bit lost in 'translation'....
Thanks
lantama
IB Autotrading / TWS restart / Order Mapping
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: IB Autotrading / TWS restart / Order Mapping
Hello Sir.
If this information is provided by API within the specified timeout period then MC catches the orders.
If TWS does not provide the requested list in the specified timeout period - MC decides that during the disconnect period – the active orders were cancelled.
You need to specify the position manually for each strategy. Please do the following:
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 it (continue the trading from the position where you have left it).If you are trading with multiple strategies on one instrument - you need to assign the position manually for each strategy.
You can assign the position automatically by means of the "syncronizer" scripts:
!From Broker To Strategy MP Synchronizer!
!From Strategy To Broker MP Synchronizer!
After reconnecting to TWS MC requests from TWS the list of active orders and partially filled orders to check the status of active orders through API.When I have placed a strategy order via IB autotrading plugin and I have a TWS restart then the order cannot be handled by MC afterwards? Mapping is lost, is this right?
If this information is provided by API within the specified timeout period then MC catches the orders.
If TWS does not provide the requested list in the specified timeout period - MC decides that during the disconnect period – the active orders were cancelled.
When you turn off the auto trading - the strategy position becomes zero.When I restart somehow MC all strategy position information is lost, as far as I know. Any idea how to save the information for the next session?
You need to specify the position manually for each strategy. Please do the following:
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 it (continue the trading from the position where you have left it).If you are trading with multiple strategies on one instrument - you need to assign the position manually for each strategy.
You can assign the position automatically by means of the "syncronizer" scripts:
!From Broker To Strategy MP Synchronizer!
!From Strategy To Broker MP Synchronizer!
Please describe what do you mean exactly and what is your goal.Rolling a futures position into the next expiry seems to be even more complicated i.m.o.
Re: IB Autotrading / TWS restart / Order Mapping
Henry, many thanks. This definetely helps. The futures position rolling should work as well. Means changing the underlying contract in the chart. Rolling the position manually into the next expiry. Turning on autotrading again. Entering position long x as starting position.....
What I really miss in MC is the posibillity to store global variables in a database or text files?!
Best regards
lantama
What I really miss in MC is the posibillity to store global variables in a database or text files?!
Best regards
lantama
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: IB Autotrading / TWS restart / Order Mapping
You need to write a custom DLL to store global variables in a text file.
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: IB Autotrading / TWS restart / Order Mapping
You can use the PRINT statement to save any variable in a text file.Henry, many thanks. This definetely helps. The futures position rolling should work as well. Means changing the underlying contract in the chart. Rolling the position manually into the next expiry. Turning on autotrading again. Entering position long x as starting position.....
What I really miss in MC is the posibillity to store global variables in a database or text files?!
Best regards
lantama
Re: IB Autotrading / TWS restart / Order Mapping
Hello LantamaHello, I am currently testing the conversion of some of my Autotrading via IB TWS from a thrid parts DLL Solution (TWSlink) to the Strategy Autotrading of MC. Some crucial points are not clear to me and I was unable to find the right answers here in this large forum....
When I have placed a strategy order via IB autotrading plugin and I have a TWS restart then the order cannot be handled by MC afterwards? Mapping is lost, is this right?
When I restart somehow MC all strategy position information is lost, as far as I know. Any idea how to save the information for the next session?
Rolling a futures position into the next expiry seems to be even more complicated i.m.o.
I am trading multiple strategies in different time compressions for the same instrument. Thus manual effort should be as minimal as possible. I am a bit lost in 'translation'....
Thanks
lantama
IB resetting is normal. To resolve that, you may use TWSSTART. This utility tool will maintain open TWS and you should not loose your data. Search the Internet for it. This is a free tool and best of all, a good support from the owner.
I use also TwsLink to send my orders, but outside MC. I know that there is a function you could use to read all your positions and stores the info in a file. You could then reload them and replace your data. Look in the help file. I don't use it, but it is planned in a future project. You may ask TWSLink owner to guide you on that
Good luck, happy trading
Martin