MC Autotrading Engine

Questions about MultiCharts and user contributed studies.
User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

MC Autotrading Engine

Postby danilo » 09 Jun 2008

Marina,

starting from release 3.0 of MC (last beta included) my strategies go often out of sync, ie the TWS report a number of positions that are different from the MC positions, I'm using the timeout for unfilled strategy & order replacement to zero, and sometimes (almost once for session) the orders are execute before to be cancelled and then re-executed since are substituted by market orders. This bugs happen only with limit and stop orders, and since this kind of orders can improve the performance of a strategy a really doesn't want miss them. Since with MC 2.1 I never had this kind of problems I'm asking to "TS Support" that when limit/stop orders are used in a strategy and the conversion timeout is set to zero, MC doesn't send any LMT/STOP orders (it doesn't make sense since should converted immediately to market orders) but instead of emulate them as already perfectly implemented in MC 2.1.

Regards,
Danilo

liang323
Posts: 27
Joined: 12 Mar 2006

Postby liang323 » 09 Jun 2008

Hello danilo, thanks for identify the problem for us.

Yes, I had the exact same problem, the 0 second time out conversion is supposed to send the market order to clear out the unexecuted limit/stop orders. However, TWS didn't do anything after the time out, no market order was sent what so ever, hence my trade went out of sync.

The latest June 4 release didn't fix the problem, the timeout conversion does not work as it suppose to.

If anyone else also identify the same problem, please drop a line here, I hope TS Support will soon acknowledge it and fix the problem.

thanks

liang323
Posts: 27
Joined: 12 Mar 2006

Postby liang323 » 09 Jun 2008

this is what I think how MC should work if the Time out is set to 0 second:

when setprofittarget is used, normally the limit order should be sent out to TWS as soon as entry is made.

However when the user choose to set the timeout conversion to 0 second, NO limit orders are sent to the TWS upon entry, instead a market order will be sent as soon as the exit order arrow is plotted on the chart. This way there won't be any chance for out of sync problem or duplicated orders to occur.

On the other hand when the timeout conversion is set > 0 second, the conversion should work in a normal fashion, ie. a limit order is sent out as soon as entry is made.
Last edited by liang323 on 10 Jun 2008, edited 1 time in total.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 10 Jun 2008

Hi guys,

The bug has been confirmed.

As soon as it's fixed, we'll release a new beta with the fix.

Regards.

liang323
Posts: 27
Joined: 12 Mar 2006

Postby liang323 » 10 Jun 2008

hello Marina, that's good news,

looking forward for the new beta release.

thanks very much

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 10 Jun 2008

Hi guys,

The bug has been confirmed.

As soon as it's fixed, we'll release a new beta with the fix.

Regards.


Hi Marina,

could you explain how the bug will be fixed ? i.e. what will be the new behaviour of autotrading engine when the timeout is set to zero ?

Danilo

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 11 Jun 2008

The idea behind the conversion is the following:

An order is submitted to the broker. Then this same order is plotted on the chart. As soon as the order is plotted on the chart, timeout is triggered. With the timeout set to zero, the conversion takes place immediately after timeout is set off.

Since the order is first submitted to the broker and then plotted on the chart, the limit/stop order might get filled even before you see anything on the chart. Of course, in this case conversion into a market order won't take place (and is totally unnecessary).

At the moment, this implementation doesn't work correctly and our engineers are working to fix it. Once the conversion works the way it's supposed to, you'll be able to achieve high precision in placing your orders thus controlling your risks.

Regards.

oakshadows
Posts: 33
Joined: 01 May 2007

Postby oakshadows » 07 Sep 2008

1. QUESTION FOR TSSUPPORT: To follow-up the thread above, when using the "Unfilled Strategy Order Replacement" in Auto Trading, if the delay for conversion of a limit order is set to "0" seconds. does Multicharts now issue a market order without first issuing and cancelling a limit order? (If so, that would enable traders to have the function of an MIT order in lieu of a limit order.)

2. QUESTION FOR MC USERS: On a separate note, are any Multicharts traders actually using the Unfilled Strategy Order Replacement in Auto Trading? Has it worked for you?

It is not working for me (trading limit orders with the conversion delay set to "1" second) with Multicharts Version 4.0 Beta 1 (Build 1440): (a) the limit order is never converted by MC to a market order in my Interactive Brokers account and (b) the MC chart shows a fill at the limit order price, even though the trading account never registered a fill. Are others having a similar experience?

cael
Posts: 89
Joined: 06 Sep 2006
Has thanked: 2 times

Postby cael » 08 Sep 2008

(b) the MC chart shows a fill at the limit order price, even though the trading account never registered a fill. Are others having a similar experience?


I have not tried but it sounds like MC is open loop. If the price ticks it is filled in MC but may not be filled by the broker. hence the need for market orders to keep sync between MC and the broker. Is this correct?

ps. Does anyone fill comfortable with market orders?

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

Postby 2haerim » 09 Sep 2008

1. QUESTION FOR TSSUPPORT: To follow-up the thread above, when using the "Unfilled Strategy Order Replacement" in Auto Trading, if the delay for conversion of a limit order is set to "0" seconds. does Multicharts now issue a market order without first issuing and cancelling a limit order? (If so, that would enable traders to have the function of an MIT order in lieu of a limit order.)

2. QUESTION FOR MC USERS: On a separate note, are any Multicharts traders actually using the Unfilled Strategy Order Replacement in Auto Trading? Has it worked for you?

It is not working for me (trading limit orders with the conversion delay set to "1" second) with Multicharts Version 4.0 Beta 1 (Build 1440): (a) the limit order is never converted by MC to a market order in my Interactive Brokers account and (b) the MC chart shows a fill at the limit order price, even though the trading account never registered a fill. Are others having a similar experience?


First of all, I do not use IB autotrading, but my own autotrading and as far as I know, V4 Beta 1 (Build 1440) has a bug and does not work correctly when Unfilled settings to 0. I think it is already fixed and will be ready in the next beta or release version.

With 0 settings, MC issues first the stop/limit order and then later when the price touches the stop/limit price, it cancels the stop/limit order and right after the cancellation, the final converted market order is issued.

I am afraid that internal autotrading could have some unknown bugs yet revealed (I understand how complicated the mechanism of autotrading engine could be, though). So it is highly recommended that users report many feedbacks about every possible situations. That way, autotrading will getting closer to the perfection.

oakshadows
Posts: 33
Joined: 01 May 2007

Postby oakshadows » 10 Sep 2008


UPDATE


Good News:

"Unfilled Strategy Order Replacement" in Auto Trading appears to work in the new MC Version 4.0 Beta 2 (Build 1573).

Bad News:

"Unfilled Strategy Order Replacement" in Auto Trading is available ONLY in Async mode, and not in Sync mode.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 10 Sep 2008

Dear Marina,

In TS8 there is a nice option under the strategy Automation Tab:

"Strategy will fill non-historical orders ONLY when the TradeManager reports them as filled"

I know that the TradeManager has not implemented yet, but I think that is not mandatory to implement this feature.

The current implementation is similar but is not the same. The requested feature has 2 advantage compared to MC implementation:

1) you can hide to the market your stop/limit orders
2) you don't have any kind of sync/fill problems

please, could you consider to implement also this nice feature ?

Regards,
Danilo

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 14 Sep 2008

As it's possible to see reading the posts, there are many user of the autotrading engine and we know the merits and defects of such engine and we are perfectly okay with Danilo.
I would also like to clarify that we are not asking to clone a defect of TS, because the system works well and there are a lot of people that use it for autotrading.

In summary we prefer a "old turtle" that always arrives at its destination that a "young hare" that does not ever arrive.

Regards

P.S.
It's a good idea to clone also the TradeManager, so we can finally debug the autotrading, especially when the same asset is traded across different strategies.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 26 Sep 2008


UPDATE


Good News:

"Unfilled Strategy Order Replacement" in Auto Trading appears to work in the new MC Version 4.0 Beta 2 (Build 1573).

Bad News:

"Unfilled Strategy Order Replacement" in Auto Trading is available ONLY in Async mode, and not in Sync mode.


Hi oakshadows,

Unfilled Strategy Order Replacement is only available in the Async mode because it is only needed in the Async mode. This measure has been introduced to ensure synchronization between the charts and the broker: the convertation "force-fills" the orders that have already been plotted on the chart, not to have discrepancies b/w the orders on the chart and those at the broker.

In the Sync mode, no such measure is necessary: only the orders that have been filled at the broker, are plotted on the chart.

Let me know if you need further clarifications.

Regards.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 26 Sep 2008

Dear Marina,

In TS8 there is a nice option under the strategy Automation Tab:

"Strategy will fill non-historical orders ONLY when the TradeManager reports them as filled"

I know that the TradeManager has not implemented yet, but I think that is not mandatory to implement this feature.

The current implementation is similar but is not the same. The requested feature has 2 advantage compared to MC implementation:

1) you can hide to the market your stop/limit orders
2) you don't have any kind of sync/fill problems

please, could you consider to implement also this nice feature ?

Regards,
Danilo


Hi Danilo,

Using the market orders will do the job (if I correctly understand what you are trying to achieve).

Regards.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 26 Sep 2008

Marina,
I would you like that you help me to understand what happen under the following scenario:

BAR: 5-min

10:00 -> signal: buy next bar at 7.85 limit (close of the bar)

Market scenario for the next 5-min (next-bar):

10:00:00 BID=8.70, ASK=8.85,TRADE=8.85 (A)
10:01:00 BID=8.50, ASK=8.65,TRADE=8.50
10:02:00 BID=8.20, ASK=8.35,TRADE=8.35
10:03:00 BID=8.00, ASK=8.15,TRADE=8.00
10:04:00 BID=7.80, ASK=7.95,TRADE=7.80 (B)
10:04:30 BID=7.90, ASK=8,05,TRADE=7.90

TS8 (*) and MC2.1 should be able to fill the order at time (B) at market price of 7.95 (0.10 slippage)

Regarding the new engine I’m not sure if and when will be filled. Supposing to have set the option to convert the limit order to market order after 30 seconds, This is what I expect to happen :

the limit order is sent to broker at the close of bar, in this example at 10:00 and then, after
30 seconds, converted at market price. The order will be filled at time (A) at market price of 8.85 (1.00 slippage)

If I set the timeout = 0, what will happen in this situation ? the result is the same as the 30s timeout ?


Thanks for Answer,
Danilo

(*) with the following autotrading option selected:
"Strategy will fill non-historical orders ONLY when the TradeManager reports them as filled"

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 01 Oct 2008

Dear Marina,

please reply on the question, I have tested both the method with the following conditions:

1) AA (timeout = 60) : in sync but the results are very differents from from backtesting since all the orders was executed "at market"

2) AA (timeout = 0) : out of sync (no comment !)

3) SA : in sync but what about backtesting ? the results are differents, and what is worse change the strategy expectations

The engine available in MC2.1, in my modest opinion, was the best proxy for the stop/limit orders (allowing a little slippage). So what I'm asking is to have the MC2.1 engine available as a option (it's also available in TS8 !).

I have written a little piece of code that implement the "limit order emulation", If I was able to implement it in few time I don't understand the problem for TS to support it in native mode:

Code: Select all

auto = (getAppInfo(aiStrategyAuto) = 1) and
          (getAppInfo(aiIntrabarOrder) = 1);

if (MarketPosition = 0) then begin

// BUY
if (auto) and (Close <= XX) then
   Buy next bar at Market              
else
   Buy next Bar at XX limit;  // for backtesting
     
// SELL
if (auto) and (Close >= YY) then
   SellShort next bar at Market;
else
  SellShort next Bar at YY limit;  // for backtesting          
     
end;


There are very few people that are really testing the autotrading, so I don't expect a lot of support to my request, but If there are I'd like to know what they are thinking about the reliability of current autotrading engine (or should be better call it : assistant-trading ?).

Regards,
Danilo

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 08 Oct 2008



BAR: 5-min

10:00 -> signal: buy next bar at 7.85 limit (close of the bar)

Market scenario for the next 5-min (next-bar):

10:00:00 BID=8.70, ASK=8.85,TRADE=8.85 (A)
10:01:00 BID=8.50, ASK=8.65,TRADE=8.50
10:02:00 BID=8.20, ASK=8.35,TRADE=8.35
10:03:00 BID=8.00, ASK=8.15,TRADE=8.00
10:04:00 BID=7.80, ASK=7.95,TRADE=7.80 (B)
10:04:30 BID=7.90, ASK=8,05,TRADE=7.90

TS8 (*) and MC2.1 should be able to fill the order at time (B) at market price of 7.95 (0.10 slippage)


That’s correct.

Regarding the new engine I’m not sure if and when will be filled. Supposing to have set the option to convert the limit order to market order after 30 seconds, This is what I expect to happen :

the limit order is sent to broker at the close of bar, in this example at 10:00 and then, after
30 seconds, converted at market price. The order will be filled at time (A) at market price of 8.85 (1.00 slippage)

If I set the timeout = 0, what will happen in this situation ? the result is the same as the 30s timeout ?


Asynchronous mode of auto trading (AAT) works in a different way compared to what you wrote:

A limit order is sent to the broker at 10:00. The arrow on the chart is plotted when the condition on TRADE has been met (time B). Once the arrow on the chart is plotted the time-out countdown begins. If within 30 seconds after the arrow was plotted the limit order does not get filled, it is converted into a market order. In this case it gets filled at the ask price of 8.05

If your timeout =0, then once the arrow is plotted in point (B), the timeout countdown is set off. Most probably the order will get filled in point (B) at the ask price of 7.95. It might happen so that it will only be filled at the next time point at the ask price of 8.05

I hope the above makes sense. Let me know if you need further clarifications.

Regards.

User avatar
danilo
Posts: 170
Joined: 02 Jan 2007
Location: Italy
Has thanked: 4 times
Been thanked: 9 times

Postby danilo » 08 Oct 2008

Marina,

Thanks for clarification, I had already asked the question several months ago, but then I had not received any response.

Regards,
Danilo


Return to “MultiCharts”