Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Fill Algorithm to change fill sequence

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom Fill Algorithm to change fill sequence

    Can we change the way the backtester assumes the sequence of events that it uses to generate fills?

    Look at the attached bar chart. In my opinion, the backtester should not have stopped me out.

    My code has:

    EnterLongStop(471.7, "le1");
    SetStopLoss(CalculationMode.Ticks, 8);

    Of course with just OHLC bar data we don't know for sure what happened intrabar, but just a casual look at the entry (and exit) bar would suggest that after the open at 470.5, we next made the low at 470.5 then the high at 472.1 then the close at 472.1. Not that its needed but the 14:07 bar, I think, helps reinforce this assumption.

    However, look at how NT executed these fills. It put me long at 471.7 (correct) then stopped me out at 470.5 (suspect). For this to have actually happened, on the 14:06 bar the market would have had to trade up to at least 471.7 (long entry fill) then down to at least 470.5 (stop loss fill) then back up to 472.1 (the close).

    Not to keep harping on Tradestation, but Tradestation's backtester would look at the 14:06 bar, and see that the open is near the low of the bar and close is near the high of the bar and assume the bar sequence was: open, low, high, close. And as such would not have stopped out at 470.5.

    Before I start studying @LiberalFillType.cs, I thought I might ask is it possible for a lowly little paying customer such as myself, to change the fill behavior of NT's backtester to mimic the way Tradestation does it? That is, look at the relationship of the close (and perhaps open) to the high and low of a bar to define the sequence that limit and stop orders are filled.

    If so, any hints or examples would be greatly appreciated.

    thanks,
    shawnj
    Attached Files
    Last edited by shawnj; 09-22-2009, 07:36 PM.

    #2
    shawnj, yes you can create custom fill algorithms - http://www.ninjatrader-support.com/H...FillTypes.html

    However per default, NinjaTrader uses the conservative approach and stops you out in this case.

    For simulating fills intrabar, you can take a look at this sample here -

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,605 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    8 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    4 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    13 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X