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

Past Plot() values

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

    Past Plot() values

    Hi,

    A quick question.
    If a DataSeries object is associated with each Plot, and is held in the Values collection, can I access past values of the plot as follows?

    Add(new Plot(Color.Red, "PlotA"));
    Add(new Plot(Color.Blue, "PlotB"));
    Add(new Plot(Color.Green, "PlotC"));

    Values[0]{3] the value of PlotA 3 bars ago
    Values[1]{1] the value of PlotB 1 bar ago
    Values[2]{0] the current bar value of PlotC

    Thank you.

    #2
    Hi Zeos6,

    Yes, Values collection can be used that way, but there is minor error in your example. Brackets are used there instead of {

    Values[0][3] the value of PlotA 3 bars ago
    Values[1][1] the value of PlotB 1 bar ago
    Values[2][0] the current bar value of PlotC
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan. Sorry for the typo and thanks for catching it.

      Comment


        #4
        Ryan, one more question please.
        Can you reassign a previous plot value? Say I have a plot value of 3 on the previous bar and now on the current bar I want to change it to 5. Can I simply say, Values[0][1] = 5? Please advise. Thanks.

        Comment


          #5
          Yes, you can but not like that. There is an additional overload in Set that allows you to set to a prior value.

          DataSeries.Set(int barsAgo, double value)
          You can also set the value for historical bars by including a "barsAgo" value that represents the number of bars ago that you want the double value to be stored at.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks Ryan. So what would this look like for a Plot? Would you use Values[0].Set(3, 5.0)?

            Comment


              #7
              Yes, works the same for plots and data series. A plot uses same structure as data series but has capability of setting a visual.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by Zeos6 View Post
                Ryan, one more question please.
                Can you reassign a previous plot value? Say I have a plot value of 3 on the previous bar and now on the current bar I want to change it to 5. Can I simply say, Values[0][1] = 5? Please advise. Thanks.
                Actually you can do that assignation, as the Values collection is read/write, but that is not the approved NT method: they recommend you use an override on the Set command.

                Comment


                  #9
                  Hi Koganam,

                  So what you are saying is that Values[0][3] = 5 will work but the preferred way is Values[0].Set(3, 5.0). Is that correct?

                  Comment


                    #10
                    Originally posted by Zeos6 View Post
                    Hi Koganam,

                    So what you are saying is that Values[0][3] = 5 will work but the preferred way is Values[0].Set(3, 5.0). Is that correct?
                    Pretty much, yes.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by MarianApalaghiei, Today, 10:49 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by love2code2trade, Yesterday, 01:45 PM
                    4 responses
                    28 views
                    0 likes
                    Last Post love2code2trade  
                    Started by funk10101, Today, 09:43 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post funk10101  
                    Started by pkefal, 04-11-2024, 07:39 AM
                    11 responses
                    37 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Yesterday, 08:51 AM
                    8 responses
                    46 views
                    0 likes
                    Last Post bill2023  
                    Working...
                    X