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 helpwanted, Today, 03:06 AM
                    1 response
                    10 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    8 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    242 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    385 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X