Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simulating MIT order in backtest

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

    Simulating MIT order in backtest

    I am sure this is a pretty basic question, and I am embarrassed to ask, but I am stuck.

    Say I have a simple rule to submit an unmanaged market-if-touched (MIT) order when price touches a moving average or some other measurement that's a moving target intra-bar because it changes as the price changes before the bar closes, and I want the order fired when price touches or crosses it.

    With CalculateOnBarClose=false, this works fine in real time; the moment price crosses the moving average, the order is fired.

    Getting this to work in backtesting, even with a secondary 1-tick data series, seems like it's harder than it ought to be. With a secondary data series added in the strategy, I expect OnBarUpdate() to be called multiple times on the primary series, just like in real time. But it isn't. It's especially important to have multiple OnBarUpdate() events on the primary series if I have a large number of things to set up in am if(FirstTickOfBar) block.

    So here's the dumb question: Is there a switch or something available to a programmer to have OnBarUpdate() be called on the primary series every time it gets called on the secondary series? Or at least twice, once on first tick of bar and once when the bar is done?

    The code to do MIT orders on live data is simple. I can't see how to do the same thing in backtest without making my code incredibly complex -- I mean, I can't exactly calculate the MIT price (like a moving average of the primary minute-bar series) on a tick series.

    -Alex
    Last edited by anachronist; 07-02-2012, 12:16 AM.

    #2
    Hi Alex, your understanding is correct - it would be fairly complex to simulate this in backtesting, as the OnBarUpdate() would only be called as the underlying series update - so to simulate getting filled as closely to your SMA price activating the MIT order you would need to recode the condition using the secondary series data.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X