• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reading an indicator from file and Plotting

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

    Reading an indicator from file and Plotting

    Hello,

    First - I would like to thank the community and helpers her in advance for the guidance.

    Problem - I have a flat file which has Date, Indicator in it. Only 2 columns. I am able to read those values in ninjascript using the StreamReader. Values come in fine, as I can see them printed on the output window.

    What I am struggling with is how to do the following

    1. Read this entire file at the begining so all values of the indicator are read in say a DataSeries.
    2. Plot the indicator in Panel 2
    3. As new data is brought in (The chart primary data is a daily frequency), the code reads the then value of the indicator from the flat file.

    I would much appreciate the help here with some code example to accomplish these tasks. I have already gone through the StreamReader code example in this forum.

    Thank you

    #2
    You don't have the date in the file? Do you know the start date of your data?

    You just need to add a Plot to you code, and change the indicator to the new/2nd panel in the chart setup.

    Comment


      #3
      Originally posted by sledge View Post
      You don't have the date in the file? Do you know the start date of your data?

      You just need to add a Plot to you code, and change the indicator to the new/2nd panel in the chart setup.

      Thank you. Yes, I have the date in first column, and can be read in the ninjascript.

      The simple Plot command plots the last value of the indicator. I am loading historical data so read the entire file on first bar and then just use the Plot command on OnBarUpdate

      That does not work and as mentioned only plots the last value it read from the file.

      If someone can drop in a code snippet, that would really help

      Comment


        #4
        Use line.Split ?

        I haven't done this on historical data, only data going forward (market replay) and only intraday timeframe (30 seconds chart).

        You'll have to use historical, and parse out your date, and compare it to the charts date, and then Plot your value.




        Code:
        while ((line = inFile.ReadLine()) != null) 
        						{
        							// Splits the line at every comma. Places each split into the string array
        							string [] split = line.Split(new Char [] {','});

        Comment


          #5
          Originally posted by sardana View Post
          Thank you. Yes, I have the date in first column, and can be read in the ninjascript.

          The simple Plot command plots the last value of the indicator. I am loading historical data so read the entire file on first bar and then just use the Plot command on OnBarUpdate

          That does not work and as mentioned only plots the last value it read from the file.

          If someone can drop in a code snippet, that would really help
          How are you populating said DataSeries. Let us see the code, if we may.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by benjamind10, Today, 07:27 PM
          0 responses
          4 views
          0 likes
          Last Post benjamind10  
          Started by YevhenShynkarenko, Today, 06:07 PM
          0 responses
          4 views
          0 likes
          Last Post YevhenShynkarenko  
          Started by StevenNelson, Today, 04:07 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by Matthew Spositi, Today, 03:28 PM
          2 responses
          8 views
          0 likes
          Last Post Matthew Spositi  
          Started by faisamtrader, Today, 01:30 PM
          2 responses
          21 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X