Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 elirion, Yesterday, 09:32 PM
    0 responses
    8 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by cre8able, Yesterday, 09:15 PM
    1 response
    8 views
    0 likes
    Last Post bltdavid  
    Started by cummish, Yesterday, 08:43 PM
    0 responses
    16 views
    0 likes
    Last Post cummish
    by cummish
     
    Started by Option Whisperer, Yesterday, 07:58 PM
    4 responses
    21 views
    0 likes
    Last Post Option Whisperer  
    Started by ETFVoyageur, 05-07-2024, 07:05 PM
    13 responses
    87 views
    0 likes
    Last Post ETFVoyageur  
    Working...
    X