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

Get Indicator Input from Excel

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

    Get Indicator Input from Excel

    I have an indicator I use on multiple charts that requires manual inputs regularly. Now I have to make these entries separately for each chart.

    What I would like to do is to make th entries once into a simple Excel sheet (one column, two or three entries) and have the indicator read those for all charts (simply by Reloading NinjaScript).

    What is the simplest code to make the spreadsheet accessible and then to read the cells I need?

    Or is there another way to do this?

    #2
    Hi,

    Unfortunately, this is outside the scope of what we can support. However, since NinjaScript is C#, you could likely accomplish what you want. Just have to google for it. I would likely take a different approach and just read in a text file that contains these values. If you start creating objects that have scope over the lifetime of an indicator, be sure to clean up these resources in the Dispose() method.

    RayNinjaTrader Customer Service

    Comment


      #3
      A text file would be fine with me -- I'm looking for the simplest way. How would I do that?

      Comment


        #4
        You will need to google for resources and samples on reading/writing to text files in .NET.

        Google and search this forum for references to StreamReader and StreamWriter.
        RayNinjaTrader Customer Service

        Comment


          #5
          An example of reading from a file

          I'm not an experienced program but here is how I read some values from a file:

          First, I added a line to the Using declarations (using System.IO:

          #region Using declarations
          using System;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Drawing;
          using System.Drawing.Drawing2D;
          using System.Xml.Serialization;
          using NinjaTrader.Cbi;
          using NinjaTrader.Data;
          using NinjaTrader.Indicator;
          using NinjaTrader.Strategy;
          //added by me
          using System.IO;
          #endregion

          Then, I added the attached code to OnBarUpdate to read four values from a file and convert to doubles.
          You are interested in the try and catch section. The part before that is specific to my code.

          Folls
          Attached Files

          Comment


            #6
            Thanks for the contribution Folls.

            We will publish some official reference files for File I/O by the end of next week.
            RayNinjaTrader Customer Service

            Comment


              #7
              Thank you Folls, I'll work on this.

              And I'm looking forward to the new reference files. How will I find them?

              Comment


                #8
                They will be posted in this section.

                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CortexZenUSA, Today, 12:53 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                0 views
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                2 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,262 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X