limit order problems with IOG and BarMagnifier=1 tick

Questions about MultiCharts and user contributed studies.
faschim
Posts: 37
Joined: 14 Jul 2009
Has thanked: 5 times

limit order problems with IOG and BarMagnifier=1 tick

Postby faschim » 03 Aug 2012

I am backtesting with IOG and 1 tick BarMagnifier setting (on 5 minute bars created from the tick data) and some of my limit orders are not getting filled when they should be. As one example, I have a limit sell at a price of 1.22940 (EURUSD w/ 1/2 pip precision) active for an entire bar. The last 2 ticks of the bar are 1.22935 and 1.22950. I checked the 2 other cases where my limit orders are not filled and it is similar to previous example, i.e. there is no tick at my limit order price but the market has traded through my limit within the intra-day bar.

User avatar
t-rader
Posts: 139
Joined: 02 Feb 2011
Location: Australia
Has thanked: 11 times
Been thanked: 27 times

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby t-rader » 03 Aug 2012

Is your chart a bid or ask chart? and do you have extended backtesting on?

faschim
Posts: 37
Joined: 14 Jul 2009
Has thanked: 5 times

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby faschim » 04 Aug 2012

backtesting mode is classic (not bid/ask data) and I am using the bar magnifer with a backtesting precision of 1 tick. The data series is 5 minute bars that are aggregated up from ticks.

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

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby Henry MultiСharts » 06 Aug 2012

Hello Faschim,

In MultiCharts 8.0 beta 3 and higher:
With IOG and Bar Magnifier enabled on historical data the script will be calculated on the Open value of the main data series, then OHLC of each bar of the detailed data series selected in bar magnifier, then on the Close of the main data series. Order is filled only on these O (base)-OHLC (detailed)-C (base) values.

That means if there was no tick at the price 1.22940 then the order would be filled on the nearest price that satisfies the conditions.

faschim
Posts: 37
Joined: 14 Jul 2009
Has thanked: 5 times

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby faschim » 08 Aug 2012

Thanks for the reply Henry.

Two points:

1) The limit order might not be getting filled on last tick of bar
After looking into this in more detail it turns out the issue is where the fill would have or rather should have happened on the last tick of bar. So perhaps there is some subtlety I am missing in my coding or there is an error in Multicharts. I have included some test code as well as the test data for the following picture. I believe the limit offer is in place until the end of the the first bar but as you can see the order is instead filled on the first tick of the next bar when it should be done on the bar. I changed the data in the 3rd bar so that it is filled a few ticks before.

[img]
picture1.png
(52.37 KiB) Downloaded 1846 times
[/img]


2) I disagree with the fill methodology (in some circumstances)
I disagree in some circumstances with the methodology described in your comments above on how a limit is filled when there is when there is no tick at the limit price. Below is the text from the 8.0 release notes:

Bar Magnifier improvement – detalization of bars was changed so that prices that were not available in a lower resolution, will not be available in a higher one (i.e. if price of 100 was not available on 1 day series, it will not be possible to fill an order at 100 on a 1 week series with bar magnifier).


The fundamental reason the above is the correct way to do it is because there is no trading in an overnight gap, i.e. 1 days series aggregated up to 1 week series and using bar magnifier. No trading can happen in a gap between the daily bars. There is no continuous trading. This is NOT fundamentally correct when I am aggregating up from tick or second bars up to say 5 minute bars. There is no trading gap. There is continuous trading. As long as the market is open I can bang my limit orders in where ever I please in the order book. Say I have a limit sell in at 1.25 and the last tick was 1.24 and the next tick is 1.26 then in my view I should be filled at 1.25. Lets assume the the next tick/trade at 1.26 was a buy. So by definition it lifted the best offer (which is 1.26 in absence of my offer at 1.25). But in backtest land my offer is ahead at 1.25 and so becomes the best offer so the buy would have lifted my offer. If the trade/tick at 1.26 was a sell then by definition it hit the best bid, in which case its clear the order book has moved up and through my offer that was sitting at 1.25 so again I am done at 1.25.

Of course this bar magnifier on ticks with limit orders is an approximation of reality (and probably not a very good one). Ideally I would have full order book data then one could do the simulations much more accurately.
Attachments
investigate_ScalpLimitOrders3.pla
(4.04 KiB) Downloaded 702 times
EURUSD tick test data.zip
(595 Bytes) Downloaded 532 times

vking
Posts: 235
Joined: 21 May 2009
Has thanked: 51 times
Been thanked: 41 times

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby vking » 09 Aug 2012

This is a very valid argument !!
Say I have a limit sell in at 1.25 and the last tick was 1.24 and the next tick is 1.26 then in my view I should be filled at 1.25. Lets assume the the next tick/trade at 1.26 was a buy. So by definition it lifted the best offer (which is 1.26 in absence of my offer at 1.25). But in backtest land my offer is ahead at 1.25 and so becomes the best offer so the buy would have lifted my offer. If the trade/tick at 1.26 was a sell then by definition it hit the best bid, in which case its clear the order book has moved up and through my offer that was sitting at 1.25 so again I am done at 1.25.

Of course this bar magnifier on ticks with limit orders is an approximation of reality (and probably not a very good one). Ideally I would have full order book data then one could do the simulations much more accurately.

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

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby Henry MultiСharts » 10 Aug 2012

We are analyzing this behavior.

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

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby Henry MultiСharts » 21 Aug 2012

1) The limit order might not be getting filled on last tick of bar
This issue is confirmed. The fix will be available for public in MultiCharts 8.1 Beta 1
2) I disagree in some circumstances with the methodology described in your comments above on how a limit is filled when there is when there is no tick at the limit price.
Thank you for your suggestion. It has been forwarded to our developers and management. We will consider such improvement in the future.

faschim
Posts: 37
Joined: 14 Jul 2009
Has thanked: 5 times

Re: limit order problems with IOG and BarMagnifier=1 tick

Postby faschim » 22 Aug 2012

Thanks Henry!

In regards to issue 2) above, the basic issue is to distinguish between periods where the market is open and there is continuous trading, e.g. main data series is say 5 minute bars and secondary IOG data series is say ticks, and periods where there is a trading gap, e.g. main data series is weekly data and secondary IOG data series is say daily bars. In the latter case there is no trading inbetween daily sessions and limit trades should not be filled in HL gaps, whereas in the former this is not the case and the limit order can be filled.


Return to “MultiCharts”