Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Preventing live orders from submitting when backtesting

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

    Preventing live orders from submitting when backtesting

    This isn't a question about the strategy analyzer itself. Rather I want to ask about running a strategy on a chart.

    Is there any way to prevent a strategy from sending a live order on the last bar? As a temporary fix I tried

    if (!Historical) return;

    at the beginning of OnBarUpdate() but it doesn't seem to matter -- if the strategy generated an order on historical data prior to the next live tick, the order gets sent.

    The reason I want to prevent this is so that my ATM backtesting framework will work properly. It uses unmanaged orders on historical data, but I want it to switch over to ATM strategies on live data, and I don't want a lingering historical order to end up sitting there in the DOM ladder.

    -Alex

    #2
    Hi Alex,

    You can work with CurrentBar in relation to Count to identify the last bar on the chart. This will depend on CalculateOnBarClose settings.

    Code:
    bool isLastBar = CalculateOnBarClose ? Count - 2 == CurrentBar : Count - 1 == CurrentBar;
    You could work that bool into your entry conditions. Pseudo code:
    if (entryCondition && !isLastBar)
    {
    }
    Last edited by NinjaTrader_RyanM1; 07-16-2012, 02:33 PM.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Working...
    X