Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add Bar Function: Return Bar Index

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

    Add Bar Function: Return Bar Index

    It would be much easier to program and maintain multi-bar strategies (multi-Instrument/multi-Time Frame) if the Add function returned the index of the new bar added in the BarsArray.

    Right now you have to explicitly remember the order in which the bars were added or maintain a counter to get the right index of the bar being added. This is error-prone since you can forget to increment the counter.

    It would be relatively straight forward to return the index of the newly added series as the return value of Add() function.

    #2
    Hello aviat72,

    Thank you for your post and suggestion.

    I will speak to someone in our NinjaSript department Monday to see if this possible or if this can be achieved. I will follow up as soon as I gather additoinal information.

    Thank you for your patience.
    Christopher J.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris.

      (1) While building more complex strategies built on top of sub-modules doing different analysis, an atomic function which immediately tells which index to use is going to be very useful. A non-atomic approach (using BarsCount etc.) can have issues if there are separate threads. I do realize that right now NT uses just one thread for the calculation and display but things may change (or the user may spawn their own threads).


      (2) I am not sure how a strategy will behave if you add a bar which already exists. Does it simply ignore the new bar being added or does it add a duplicate?

      If it does ignore and not add then returning an error code (-1) would help debug and fix things. This is especially relevant when you are trying to backtest and optimize and varying the time-frames to use.
      Last edited by aviat72; 04-24-2010, 02:08 PM.

      Comment


        #4
        1. Thank you for your suggestions. I have added it to our feedback list.

        2. When you add a duplicate Bar series to a strategy you will just have a duplicate series.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        595 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X