Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Board game geek, Yesterday, 02:20 AM
    2 responses
    20 views
    0 likes
    Last Post Board game geek  
    Started by jackiegils, Yesterday, 11:05 PM
    0 responses
    5 views
    0 likes
    Last Post jackiegils  
    Started by cre8able, 05-09-2024, 09:15 PM
    2 responses
    17 views
    0 likes
    Last Post cre8able  
    Started by Trader146, Yesterday, 09:17 PM
    0 responses
    9 views
    0 likes
    Last Post Trader146  
    Started by ttrader23, 05-08-2024, 09:04 AM
    9 responses
    43 views
    0 likes
    Last Post ttrader23  
    Working...
    X