Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Streamreader

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

    Streamreader

    In the streamreader indicator sample in the reference section ("SampleStreamReader"), my understanding is this example is for reading in historical data stored externally for use in an indicator (or strategy)--values typically stored by date.

    Why does the code then exclude any 'historical'date through the line

    if (Historical)
    return;

    ?

    I want to read values for my own variables (not O,H,L,C) for all dates in my external file--should I leave this line out?

    Is streamwriter the best option for doing this?
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    Jim-Boulder, that line is there so it doesn't try to read from a file every single time a bar is updates. For example, if you were backtesting this code it would run on every bar of the backtest, which could be many, many bars.

    If you want to read variables from a file, it would probably be best to read that files once, right at the beginning of the script running. You can run code just once at the beginning like this:
    Code:
    OnBarUpdate()
    {
      if (CurrentBar == 0)
      {
        // do one time calculations, or load data from an external file here
      }
    }
    Generally, StreamReader isn't useful to read in historical data every bar. It would be difficult to integrate this data into your strategy anyways.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    607 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    353 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    560 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    561 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X