IB Autotrading / TWS restart / Order Mapping

Questions about MultiCharts and user contributed studies.
lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

IB Autotrading / TWS restart / Order Mapping

Postby lantama » 28 Oct 2011

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

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

Re: IB Autotrading / TWS restart / Order Mapping

Postby Henry MultiСharts » 28 Oct 2011

Hello Sir.
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?
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.
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 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?
When you turn off the auto trading - the strategy position becomes zero.
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!
Rolling a futures position into the next expiry seems to be even more complicated i.m.o.
Please describe what do you mean exactly and what is your goal.

lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Re: IB Autotrading / TWS restart / Order Mapping

Postby lantama » 29 Oct 2011

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

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

Re: IB Autotrading / TWS restart / Order Mapping

Postby Henry MultiСharts » 31 Oct 2011

You need to write a custom DLL to store global variables in a text file.

User avatar
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

Postby TJ » 31 Oct 2011

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
You can use the PRINT statement to save any variable in a text file.

lantama
Posts: 96
Joined: 20 Apr 2008
Has thanked: 5 times
Been thanked: 5 times

Re: IB Autotrading / TWS restart / Order Mapping

Postby lantama » 31 Oct 2011

PRINT is it... thanks TJ, I missed that.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: IB Autotrading / TWS restart / Order Mapping

Postby arjfca » 31 Oct 2011

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
Hello 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


Return to “MultiCharts”