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

Access indicator values

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

    Access indicator values

    Hello,

    is it possible to get access by code to all the indicator values of a bar chart like it is shown in the data box. For example I would like to know all the values ten bars ago.

    Regards,

    Thomas

    #2
    Originally posted by FTrader View Post
    Hello,

    is it possible to get access by code to all the indicator values of a bar chart like it is shown in the data box. For example I would like to know all the values ten bars ago.

    Regards,

    Thomas
    Here is a reference sample how to access indicator values correctly:

    Comment


      #3
      Hello Thomas,

      Thank you for your post.

      You can access several different values from # bars ago. For example the Open, High, Low and Close of 10 bars ago could be accessed with the following methods:
      • Open[10]
      • High[10]
      • Low[10]
      • Close[10]

      For information on Data types that can be called in NinjaScript please visit the following link: http://www.ninjatrader.com/support/h...properties.htm

      For information on referencing the correct bar please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=4769

      Please let me know if I may be of further assistance.

      Comment


        #4
        Greetings, I guess the answer does not fully solve the problem. Let's say I need to export not only High and Low of a specific bar, but also corresponding values of all indicators (which are of course unknown when writing the script) in the chart. So, first I need to know which indicators are present in the chart. E.g. I add EMA and MACD indicators, how do I find it out in the NinjaScript, in another indicator? When I have a reference to them, I suppose I can easily access their values using their IDataSeries[BarsAgo]. Thank you.

        Comment


          #5
          Originally posted by mantak007 View Post
          Greetings, I guess the answer does not fully solve the problem. Let's say I need to export not only High and Low of a specific bar, but also corresponding values of all indicators (which are of course unknown when writing the script) in the chart. So, first I need to know which indicators are present in the chart. E.g. I add EMA and MACD indicators, how do I find it out in the NinjaScript, in another indicator? When I have a reference to them, I suppose I can easily access their values using their IDataSeries[BarsAgo]. Thank you.
          After I make the usual caveat about ChartControl being unsupported, and so risky to use, as NT can change it anytime that they wish with no notice (that is what unsupported portends), the indicators on a chart are merely another collection of objects, so you can query them.

          Here is some code to do so, and output their names. You are most certainly going to have to massage the code to get what you seek, but evidently each indicator on the chart can be individually accessed.

          Code:
                      if (CurrentBar == 0) 
                          for (int index = 0; index < ChartControl.Indicators.Length; index++) 
                              Print ("ChartControl.Indicators " + "[" + index.ToString() +"] is " + ChartControl.Indicators[index].Name);
          Open the Output Window and you will see the what the return is.

          Comment


            #6
            That's it, great, thanks a lot.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,610 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            9 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            19 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            6 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            22 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X