Attached orders on brokers' server

Questions about MultiCharts and user contributed studies.
TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Attached orders on brokers' server

Postby TraderWalrus » 11 Dec 2016

I am trading Forex with IB, running Easylanguage strategies via Multicharts. I would like to be able to submit limit orders with *attached* stop, on the server side.

I have found this was submitted as a feature request in the following link, with no status:
https://www.multicharts.com/pm/public/m ... s/MC-1064/

When submitting a limit order, as long as the order isn't executed there is no protection on the server side of the broker. In case I lose connection (or anything goes wrong on my side), I am exposed to unlimited risk if this order does get executed.

If I submit both a limit and stop orders (on the same "level", meaning the stop isn't attached to the limit), then the stop may get hit first and act as the entry order to the position, obviously not what's intended here.

Since my strategies run 24 hours and obviously are not continuously monitored, I am not willing to take this risk. I had many cases of connection loss due to one reason or another. I opted then to using market orders to enter a position once the market arrives to the desired price to avoid this risk. Once the market order is executed my strategy adds a stop immediately. This however creates problems of latency and slippage, as well as a larger distance in performance between backtesting results and live trading.

IB's API provides the possibility to have attached orders. Is there no way to achieve it through Multicharts?

A similar question regarding LMAX: this broker does not have OCO, but they do have "Contingent Orders" which are basically a bracket attached to the main order. Their API supports this mechanism. Is there a way to send such orders (that will exist in this form on LMAX's side) through Multicharts?

wullenweber helmut
Posts: 57
Joined: 21 Dec 2007
Has thanked: 2 times
Been thanked: 9 times

Re: Attached orders on brokers' server

Postby wullenweber helmut » 12 Dec 2016

This can be done with a DLL like this one:

https://trade-commander.com/twslink/

I have experienced TWSlink with Excel and it worked fine, sending "native" Bracket Orders to TWS, i.e. Stop and Exit are attached to the parentorder in one ordergroup. The same could be done in EasyLanguage.

Of course it would be a great deal, if Multicharts would provide their customers with a DLL like this one!

The DLL can also be used to generate orders in one underlying depending a condition in second underlying.
For example: Buy SPY Call xyz if SPY > pricelimit or buy share A if Index-Future B reaches level xyz.

User avatar
Smoky
Posts: 411
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 67 times
Been thanked: 105 times

Re: Attached orders on brokers' server

Postby Smoky » 13 Dec 2016

MANY THANKth ! with this dll you can do all MC can't do !

note :

Event polling for active event control (you decide to check, if something happens, like a fill)
Callback hooks in up to 6 different threads for passive event control (your callback is called, when something happened)

User avatar
Smoky
Posts: 411
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 67 times
Been thanked: 105 times

Re: Attached orders on brokers' server

Postby Smoky » 13 Dec 2016

DefineDLLFunc: "TWSLINK2.DLL",int, "WAIT_FOR_ORDER_STATUS",
int,{uidorder}
int,{statusid}
int,{timeoutmilliseconds}
int;{statusidbreak}

DefineDLLFunc: "TWSLINK2.DLL",int, "WAIT_FOR_FILLED",
int,{uidorder}
int;{timeoutmilliseconds}

DefineDLLFunc: "TWSLINK2.DLL",int, "WAIT_FOR_SUBMITTED",
int,{uidorder}
int,{timeoutmilliseconds}
int;{sub_stat_only}

DefineDLLFunc: "TWSLINK2.DLL",int, "WAIT_FOR_ORDER_STATUS_RNG",
int,{uidorder}
int,{lowerstatusid}
int,{upperstatusid}
int,{timeoutmilliseconds}
int;{statusidbreak}

DefineDLLFunc: "TWSLINK2.DLL",int, "GET_ORDER_STATUS",
int;{uidorder}

DefineDLLFunc: "TWSLINK2.DLL",int, "GET_ORDER_ERROR",
int;{uidorder}

very Nice tool ! ! !

User avatar
Smoky
Posts: 411
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 67 times
Been thanked: 105 times

Re: Attached orders on brokers' server

Postby Smoky » 14 Dec 2016

For TWS API you can follow this link :

https://interactivebrokers.webex.com/mw ... 3158540%26

their webinars are realy good !

TraderWalrus
Posts: 63
Joined: 13 Sep 2016
Has thanked: 30 times
Been thanked: 8 times

Re: Attached orders on brokers' server

Postby TraderWalrus » 16 Jan 2017

Back to this topic - as I understand, using this DLL means marketposition and marketposition_at_broker_for_the_strategy will not return correct information.

In this case we will have to use marketposition_at_broker, with correct results received if the strategy is the only generator of orders for the instrument.

Is there a way to send the orders and make the strategy aware they were sent?


Return to “MultiCharts”