Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical data issue in adding instrument

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

    Historical data issue in adding instrument

    Hi,

    Please help me out this issue.when I have 10 days data for both instrument OnBarUpdate method is call properly. But when I have only primary instrument 10 days data and not have 10 days data for second instrument . OnBarUpdate method is not call at that time. I set DaysToLoad = 5 or 10 but its behavior is same. I only perform my calculation on primary instrument when running on historical data. Second instrument only use when we are running strategy for live not any calculation is done on historical data so why i need historical data for this second instrument?

    Here is a script which i used to simple test on this situation

    protected override void Initialize()
    {
    Add(PeriodType.Minute, 1);
    Add(PeriodType.Minute, 10);
    Add("$EURUSD", PeriodType.Minute, 1);
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    SyncAccountPosition = false;
    ExitOnClose = false;
    Unmanaged = true;
    Enabled = true;
    CalculateOnBarClose = false;
    }
    protected override void OnBarUpdate()
    {
    if(BarsInProgress == 0)
    {
    Log( "Running on historical data",LogLevel.Information);
    }
    }

    This string print in a log "Running on historical data" if I have both instrument historical data and if I have only primary instrument historical data this string is not printed in a log.

    #2
    OnBarUpdate is not called until all bars series "BarsRequired" are satisfied:



    By default the Bars Required will be 20 and if there is not historical data for the second instrument, OnBarUpdate will not run until there are at least 20 bars.

    If you do not need historical data and can allow your strategy to run on real-time, you can set your BarsRequired as low as 0.
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 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