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 Plot Values

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

    Access Indicator Plot Values

    I've searched the forum for ways to be able to access the values from an indicator from prior bars but am confused on how to do it. I see that you may be able to use the unsupported ChartControl and maybe that is the way that it needs to be tackled.

    Specifically I am trying to access the values for ZigZagDots in the ZigZagUTC indicator.
    Can anyone help with that?

    I've figured out the index of the ZigZagUTC indicator is 1 but can't figure out how to grab that ZigZagDot value from a bar 10 bars ago.

    #2
    Did you try ZigZagDot[10]?

    Comment


      #3
      You shouldn't need to access chart control to get past values. Using the indicators array you should be able to pull a previous value.

      Please see the following resource on using [] brackets

      MatthewNinjaTrader Product Management

      Comment


        #4
        I've tried almost every combination that I can think of and still can't get the values to show up.

        Here is the last things I've tried.

        double myDouble;
        myDouble = ZigZagUTC(myDataSeries,3, 5, true, Color.White).ZigZagDot.Get(10)

        I've also tried
        myDouble = ZigZagUTC(myDataSeries,3, 5, true, Color.White).ZigZagDot[10];

        Maybe it's just not possible to get those values out....may have to figure out how to modify the original ZigZagUTC so that I can get them out.

        Just too new to the NinjaScript language yet to understand how it works.

        Comment


          #5
          You may need to modify the ZigZagUTC to expose those plots or data series.

          Please see our Reference Sample on how to do this:

          MatthewNinjaTrader Product Management

          Comment


            #6
            I did look at that last night and it looks to me that it should be exposed as the code in the original ZigZagUTC looks like this

            the line that sets the Dot is one of these

            if (showdots) ZigZagDot.Set(CurrentBar-lastlobar, lastlo);

            or

            ZigZagDot.Set(CurrentBar-lasthibar, lasthi);



            #region Properties
            [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
            [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
            public DataSeries ZigZagDot
            {
            get { return Values[0]; }
            }

            am I missing something?

            Comment


              #7
              Can you upload the version of the ZigZag indicator you're using?
              MatthewNinjaTrader Product Management

              Comment


                #8
                Yep, Here you go.
                Attached Files

                Comment


                  #9
                  I'm not having any issues accessing this data. Can you try the following:

                  Code:
                  			if(CurrentBar <3)
                  				return;
                  			
                  			double test = ZigZagUTC(3, 2, true, Color.Empty).ZigZagDot[3];
                  			
                  			Print(test);
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    That code does produce numbers and a lot of them, just not correct ones.

                    For example, I'm looking at a YM 12-12 5min chart and I have a Dot at 12855 and 12691 I'm using the ZigZagUTC with parameters of show 3, span 5, HiLo true, and Color.White

                    In my code I set it up as you have described above with the code
                    DotBar = Count - CurrentBar;
                    double test = ZigZagUTC(3,5,true,Color.Empty).ZigZagDot[5];
                    Print ("Bar " + DotBar + " is " + test);

                    and I get this
                    Bar 18 is 12799
                    Bar 17 is 12788
                    Bar 16 is 12805
                    Bar 15 is 12833
                    Bar 14 is 12840
                    Bar 13 is 12844
                    Bar 12 is 12851
                    Bar 11 is 12842
                    Bar 10 is 12838
                    Bar 9 is 12833
                    Bar 8 is 12832
                    Bar 7 is 12833
                    Bar 6 is 12825
                    Bar 5 is 12828
                    Bar 4 is 12821
                    Bar 3 is 12825
                    Bar 2 is 12827

                    Comment


                      #11
                      Originally posted by shoedad View Post
                      That code does produce numbers and a lot of them, just not correct ones.

                      For example, I'm looking at a YM 12-12 5min chart and I have a Dot at 12855 and 12691 I'm using the ZigZagUTC with parameters of show 3, span 5, HiLo true, and Color.White

                      In my code I set it up as you have described above with the code
                      DotBar = Count - CurrentBar;
                      double test = ZigZagUTC(3,5,true,Color.Empty).ZigZagDot[5];
                      Print ("Bar " + DotBar + " is " + test);

                      and I get this
                      Bar 18 is 12799
                      Bar 17 is 12788
                      Bar 16 is 12805
                      Bar 15 is 12833
                      Bar 14 is 12840
                      Bar 13 is 12844
                      Bar 12 is 12851
                      Bar 11 is 12842
                      Bar 10 is 12838
                      Bar 9 is 12833
                      Bar 8 is 12832
                      Bar 7 is 12833
                      Bar 6 is 12825
                      Bar 5 is 12828
                      Bar 4 is 12821
                      Bar 3 is 12825
                      Bar 2 is 12827
                      This is as I would expect.

                      The code that sets the dots is very specifically setting dots at only the highs and lows. The Plot is undefined for all other bars, as it is never set. If you try to read undefined values, you are liable to get garbage results.

                      Maybe if you defined the end result that you are trying to achieve, someone can show you how to go about it?

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by samish18, Today, 01:01 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post samish18  
                      Started by WHICKED, Today, 12:56 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post WHICKED
                      by WHICKED
                       
                      Started by Spiderbird, Today, 12:15 PM
                      2 responses
                      11 views
                      0 likes
                      Last Post Spiderbird  
                      Started by WHICKED, Today, 12:45 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post WHICKED
                      by WHICKED
                       
                      Started by FrazMann, Today, 11:21 AM
                      2 responses
                      8 views
                      0 likes
                      Last Post NinjaTrader_ChristopherJ  
                      Working...
                      X