Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot Value N Bars Back

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

    Plot Value N Bars Back

    Hi,

    I have a question related to plots. If on the current bar I calculate a value, is there a way to plot this calculated value say N bars back, or N bars into the future? also, is it possible to plot this calculated value at a specific bar number or bar time?

    Any help would be greatly appreciated. Thank you.

    #2
    Hello Zeos6,

    You can set a plot for any existing bar by using the barsAgo index for that bar.

    For example:

    Value[5] = 100;

    This would set the bar 5 bars ago to a value of 5.



    You can set a indicator plot to project into the blank space to the right of the chart by setting the Displacement.


    Displacement doesn't change the barsAgo values, it simply shifts the entire plot forward on the chart.

    You would need to calculate a barsAgo value by subtracting that bar's number from CurrentBar to set a specific bar in the past.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      Thank you. I had thought that but I have a statement

      Code:
      Values[3][BarRef] = barValue - offset;
      that is not plotting so I thought that perhaps I had the syntax incorrect.

      Comment


        #4
        Hello,

        The syntax appears correct.

        Are your bars ago values valid indexes?

        Are you adding any prints to ensure the value is set, and including the barsAgo value used and time of that bar (meaning Time[BarRef]) to match with the chart?

        If so, please include the output from the print and a screenshot of the chart at the time of that bar and price in the print.

        Also, are you ensuring that the bars immediately before and immediately after also are set?

        (For a line plot, there must be at least two consecutive bar values set for a plot to appear)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB,

          Bingo! You may have hit it on the head.

          Also, are you ensuring that the bars immediately before and immediately after also are set?
          (For a line plot, there must be at least two consecutive bar values set for a plot to appear)
          I am using

          Code:
          AddPlot(new Stroke(Brushes.DarkMagenta), PlotStyle.Cross, "A_Top");
          Plots[3].Width = 2;
          However I do not necessarily have a value at every bar. Can you suggest how I can plot isolated points when I may not have preceding or successive values? The other Plot parameters are valid. Thank you.

          Comment


            #6
            Hi Zeos6,

            Either don't use a line plot and use bar or dot or something..


            Or anytime you are going to set the plot, check to see if the previous value is set, and if its not set, then set the previous bar to this bars value. (It would just be a floating horizontal line connecting those two points)
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi ChelseaB,

              Thank you for your reply. I am, however, a bit confused by your statement:

              Either don't use a line plot and use bar or dot or something.
              I am using PlotStyle.Cross which is not a line plot so it should work, no?

              Comment


                #8
                Hello Zeos6,

                Thank you for your response.

                You could set any plot value that does not have a value as the previous and then it's color as Transparent. For example:
                Code:
                if (yourConditionToPlot != true)
                {
                Values[0][0] = Values[0][1];
                PlotBrushes[0][0] = Brushes.Transparent;
                }
                For information on PlotBrushes please visit the following link: http://ninjatrader.com/support/helpG...lotbrushes.htm

                Please let me know if you have any questions.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                598 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                343 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                556 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                555 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X