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 Value from all Indicators in a Chart

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

    Get Value from all Indicators in a Chart

    Hi,

    Is it possible to acces and get the value of all Indicators, that are in a Chart?
    So, if I have an indicator, from which I don't know the code, can I get its value and print it to a file?

    Thx,

    #2
    Originally posted by artson View Post
    Hi,

    Is it possible to acces and get the value of all Indicators, that are in a Chart?
    So, if I have an indicator, from which I don't know the code, can I get its value and print it to a file?

    Thx,
    Yes, but it is convoluted and non-trivial.

    Maybe if you stated your larger purpose, someone might be able to show you how to achieve it in a different and easier manner. Why would you need to query the chart for its indicators, if you can simply let your indicator load a copy of the specific indicator that you want and query that?

    Comment


      #3
      Hi,

      koganam: what do you mean by:
      "let your indicator load a copy of the specific indicator that you want and query that"

      I only want in a programm to know the values from an indicator being ploted in a Chart.
      Really I want to print it out to a text file, to be able to study it later....

      I think I read it was possible to "jump" throug the indicators on a chart and to get its value...
      This is what I was asking for..., but, of course, I you know an easier way, please

      Comment


        #4
        Originally posted by artson View Post
        Hi,

        koganam: what do you mean by:
        "let your indicator load a copy of the specific indicator that you want and query that"

        I only want in a programm to know the values from an indicator being ploted in a Chart.
        Really I want to print it out to a text file, to be able to study it later....

        I think I read it was possible to "jump" throug the indicators on a chart and to get its value...
        This is what I was asking for..., but, of course, I you know an easier way, please
        So are you saying then that you want to manually load an indicator on a chart, then use an indicator to read the values of the indicator that you have manually loaded on the chart?

        Comment


          #5
          Hi,

          I want to print to a text file the values from an indicator. I cannot acces to the code from this indicator to print out the plot.....

          Comment


            #6
            Hello arston,

            Thanks for your post.

            You could attempt something like the below:

            Code:
            lock (ChartControl.Indicators)
            {
                foreach (IndicatorBase indi in ChartControl.Indicators)
                {
                    for (int i = 0; i < indi.Plots.Count(); i++)
                    {
                        if (indi.Plots[i] != null)
                        {
                            for (int j = 0; j < indi.Values[i].Count; j++)
                            {
                                Print(String.Format("Name: {0}, Index: {1} Value: {2} PlotName: {3}", indi.Name, j, indi.Values[i].GetValueAt(j), indi.Plots[i].Name));
                            }
                        }
                    }
                }
            }
            However, this code should not be used in OnBarUpdate, and would be best performed from a user event like from a button press (see example attached.)

            Keep in mind, this looks at all indexes for all plots from all indicators on the chart. If the indicator exposes data in another fashion, additional code would be needed to read those properties. An example for writing to file with a StreamWriter can be found below.

            It also may be easier to add create an indicator that adds the indicators that you want to see and write those indicator values to file as OnBarUpdate processes each bar.

            SampleStreamWriter - https://ninjatrader.com/support/help...o_write_to.htm

            Please let us know if you have any questions.
            Attached Files
            Last edited by NinjaTrader_Jim; 04-12-2021, 06:40 AM.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thanks a lot Jim

              I'll try to "digest" your explanation and your code, as I'm not even a beginner in programming........

              Comment


                #8
                Hello artson,

                Also to consider, we do have an EcoSystem of vendors and consultants who would be happy to build a tool for your that accomplishes this task at your request.

                If this is something that interests you, please let me know and I can have a representative of our EcoSystem reach out with additional information.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  This is exactly what I'm looking for...as it will allow me to customize my own routines that will read DataBox Plots values directly. Many thanks!!!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by JonesJoker, 04-22-2024, 12:23 PM
                  8 responses
                  41 views
                  0 likes
                  Last Post JonesJoker  
                  Started by timko, Today, 06:45 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post timko
                  by timko
                   
                  Started by Waxavi, 04-19-2024, 02:10 AM
                  2 responses
                  38 views
                  0 likes
                  Last Post poeds
                  by poeds
                   
                  Started by chbruno, Yesterday, 04:10 PM
                  1 response
                  44 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by Max238, Today, 01:28 AM
                  1 response
                  25 views
                  0 likes
                  Last Post CactusMan  
                  Working...
                  X