Forex automation

Questions about MultiCharts and user contributed studies.
brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Forex automation

Postby brendanh » 14 May 2009

I trade forex and am experiencing automatic broker fills that are not filled on chart. This is because the chart displays bid prices, but the broker fills buy stop orders at ask prices (by default).

So if the spread is 4 pips, and the chart price rises to within 4 pips of the stop price, it will be filled at broker but not on chart. This can cause the strategy to become out of sync with real world.

To counter this, I have reconfigured the IB order preset for forex so stop orders are triggered by the mid rather than bid\ask price. However there is still a 2 pip area that will still cause strat\RW seperation. Also this means I get 2 pip worse fills.

What is the solution to this issue? I cannot use Sync mode because IB disconnects every night, so when autotrading is restarted, interday positions would not be exited.

I think the solution is to create a new synchronisation feature. As a systems trader, I want the RW to adopt my strategy postions, not the other way around. Thus in addition to having a feature that converts chart-filled stop\limit orders to market after x broker-unfilled seconds, I suggest another timer that does the opposite is introduced. In the event a API stop\limit order is broker-filled but not chart-filled, after x seconds, two new orders are placed:

1. An offset market order, to bring the RW position back into line with the chart.
2. Another exit order at the original price.

It should not be possible to set this timer to < 30 seconds because this could cause a loop that would cost a lot of commissions.

What do you think? I can't think of another way to resolve this. Is it possible to create a mid price series that is tradeable in MC?

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

Postby Marina Pashkova » 14 May 2009

Dear Brendan,

If you use all of the settings below, strategy trading on the charts and at the broker will match each other more precisely.

1. Use the extended backtesting mode in Strategy -> Properties -> Backtesting. This feature is available in beta 6 and allows using both bid and ask series to generate orders (buys and sells). Simply plot a bid and an ask series in the same chart and then enable the extended backtesting mode.

2. Use conversion of unfilled limit and stop orders into market orders (I did not quite understand from your post if you have been using this option).

3. Use conversion of partially filled orders into market orders (available in MC 5.0 beta 6).

The first recommendation will make chart trading much more realistic. The other two will help to further improve the chart's performance.

As for your suggestion to make the real-world trading match the situation on the chart, could you please elaborate on the practical value of doing so? We could discuss the technical details later, for now we want to understand what the potential benefits are.

Also, in your post you are saying that two orders should be generated. What would the second order (exit with the original price) do?

Thank you.

SUPER
Posts: 632
Joined: 03 Mar 2007
Has thanked: 105 times
Been thanked: 81 times

Postby SUPER » 14 May 2009

Brendanh,
What is the solution to this issue? I cannot use Sync mode because IB disconnects every night, so when autotrading is restarted, interday positions would not be exited.
To keep IB running at all times there are two options:

1) Use TWStart, it stops IB from closing (its free)

http://twsstart.free.fr/

2) Manually change the AutoLog off timer am to pm and vice versa to keep IB running 24/5 days ( I used to do it before switching to TWStart)

To Keep "Autotrade Mode ON" after IB resets use maximum value of 86400 seconds for "Disable auto trading after .... seconds on the connection loss" see image.
Attachments
IB-1.JPG
IB-1.JPG (34.38 KiB) Viewed 1157 times

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 14 May 2009

Thanks Super. I already use TWSStart and toggle the AM/PM setting. I still find MC disconnects from IB TWS in the early hours (around 5:15am BST) even though IB is still running. I'll try increasing the connection time out.

There are many other, unexpected causes for broker disconnection too though (signal bug, failure in software\power\internet\OS, etc) so I'm not keen to use Sync mode.

User avatar
TJ
Posts: 7191
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 990 times
Been thanked: 2049 times

Postby TJ » 14 May 2009

IB re-boots its servers everyday.

the outage can be 30 sec to a few minutes.

depends on which server you are connected to, the reboot time is different.

US server ~ ET midnight
HK server ~ ET 1600

don't know about the UK server.

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 14 May 2009

Dear Brendan,

If you use all of the settings below, strategy trading on the charts and at the broker will match each other more precisely.
1. I've added a new symbol containing the ask series, but when I go onto the Backtesting tab, only the bid series symbol is listed in the drop down. I can't find any documentation for this feature in the Help system, will it allow me to autotrade live using both bid and ask series, or is this only for calculating historical trade performance? I hope the former.

2 & 3. Yes already using unfilled and partial price to market order conversion thanks.

My suggestion is a workaround to get chart and broker back into sync after separation occurs due to broker but not chart fill. Hopefully I can figure out item 1, which if it allows live trading using both bid and ask, would be the ideal solution as it will prevent the chart\broker discrepancy happening in the first place. Perhaps I'm being dumb, I'll try again in the morning.

Thanks Marina.

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 15 May 2009

No still can't figure how to make the second symbol available on the Backtesting drop-down lists. I have a chart with two symbols, both in subchart #1, I've tried ticking Merge Data Sources into a Single Chart. Also tried changing the symbol to History and Real Time to no avail. Can you reproduce this?

However this doesn't matter if both price series can't be used for live trading (?).

User avatar
Andrew Kirillov
Posts: 1589
Joined: 28 Jul 2005
Has thanked: 2 times
Been thanked: 31 times
Contact:

Postby Andrew Kirillov » 18 May 2009

Brendan,
If you want to use bid and ask data streams you have to add them both and make sure that in Format Symbol->Settings-> Quote Field->Bid is selected for Bid data series. The same must be done for Ask series. As soon as you do it MultiCharts will show both streams in the drop-down menu.

SUPER
Posts: 632
Joined: 03 Mar 2007
Has thanked: 105 times
Been thanked: 81 times

Postby SUPER » 18 May 2009

Brendan,
If you want to use bid and ask data streams you have to add them both and make sure that in Format Symbol->Settings-> Quote Field->Bid is selected for Bid data series. The same must be done for Ask series. As soon as you do it MultiCharts will show both streams in the drop-down menu.
Andrew,

Let us say I have selected your Extended backtesting incorporating bid/ask series data with above setting in quote manager, now do I need to have

A) bid/Ask displayed on chart
B) bid/ask data merged
C) use trade series.

Will appreciate your clarification.

Regards
Super

User avatar
Andrew Kirillov
Posts: 1589
Joined: 28 Jul 2005
Has thanked: 2 times
Been thanked: 31 times
Contact:

Postby Andrew Kirillov » 18 May 2009

You say "above setting in quote manager". This is incorrect. You should select what I suggested in MultiCharts. You add bid and ask data series the way I indicated and select extended mode. All things are done on the charts.

SUPER
Posts: 632
Joined: 03 Mar 2007
Has thanked: 105 times
Been thanked: 81 times

Postby SUPER » 18 May 2009

Andrew,

Thanks for your clarification, will try out you suggestion.

Regards
Super

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 20 May 2009

FYI, I got this working with the help of Marina. The Bid and Ask series used on the Backtesting tab need to be from the same symbol, and the same data provider. I was using TS's bid and IB's ask.

I will see over the coming days whether this has solved the chart\broker mismatch for buy stop orders.

brendanh
Posts: 158
Joined: 07 Apr 2007
Has thanked: 1 time

Postby brendanh » 10 Jun 2009

I will see over the coming days whether this has solved the chart\broker mismatch for buy stop orders.
Just a quick note to say I've been trading over two weeks since adding both bid and ask series, and it has solved the chart\broker mismatch. Thanks Andrew and Marina for providing the perfect solution.


Return to “MultiCharts”