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

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 trilliantrader, 04-18-2024, 08:16 AM
          4 responses
          18 views
          0 likes
          Last Post trilliantrader  
          Started by mgco4you, Today, 09:46 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by wzgy0920, Today, 09:53 PM
          0 responses
          9 views
          0 likes
          Last Post wzgy0920  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          10 views
          0 likes
          Last Post Rapine Heihei  
          Working...
          X