[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why wouldn't TS fill this limit order?



PureBytes Links

Trading Reference Links

In backtesting a daytrading strategy I'm developing, it sometimes
works and sometimes doesn't, for no reason I can see.

What I do when a signal condition is met, is place three orders for
the next bar:

1. Limit order to enter the market
2. Limit order to take profit (ExitLong or ExitShort)
3. Stop order to exit (ExitLong or ExitShort at stop)

Either of the exits may occur on the same bar that the entry occurs,
provided the entry order is filled.

This actually works.  Sometimes.  I see bars where the strategy
correctly enters the market and then exits on the same bar, at the
correct price.

I have calculations that set the order price, and if it's nonzero
in the case of a buy or sell condition, then the following code is
executed:

For buying:

    if orderprice > 0 then begin
        buy("B") qty contracts next bar at orderprice limit;
        ExitLong("LX0") next bar at orderprice-initstop stop;
        ExitLong("LP0") next bar at orderprice+targetprofit limit;
    end;

For selling:

    if orderprice > 0 then begin
        sell("S") qty contracts next bar at orderprice limit;
        ExitShort("SX0") next bar at orderprice+initstop stop;
        ExitShort("SP0") next bar at orderprice-targetprofit limit;
    end;

Targetprofit and initstop are 2 points.  I see a case where a sell
order is filled and profit taken on the same bar.  OK, fine, I know
that works.

Then I see a case where a buy order is filled at 983.50 but the high
of the bar at 2 points profit, 985.50 does not result in a fill of
the limit order to exit at 985.50.  Instead, it stops out at a loss
on the following bar.

Anybody have any idea why a limit order wouldn't get filled, if the
price data stream contains a price (in this case the bar high) at the
exact price of the limit order?

If it matters, I'm using 3-minute bars on ES made from ES tick data.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com