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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    43 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X