Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Method for projecting price bars forward?

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

    Method for projecting price bars forward?

    I have a general question about how to project price movement forward.... just the method for scripting it I mean?

    The projection could be either bars, or even lines, but I'm wondering what type of methods i could use for doing this?

    An example would be in the picture attached.
    Attached Files

    #2
    forrestang, there would be unfortunately no dedicated method for futures bars plotting, you would need to custom code by drawing for example into the future, the draw object overloads would accept a future DateTime anchor as parameter.

    Comment


      #3
      Are you saying the only way would be to use one of those plot void overide functions? I.e. the custom plotting that isn't supported by NT?

      Comment


        #4
        That would be an option as well, but I was referring to using the Draw Methods (DrawLine, Dot, Ray etc) to construct your forecast, those take a future DateTime input to draw at.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          That would be an option as well, but I was referring to using the Draw Methods (DrawLine, Dot, Ray etc) to construct your forecast, those take a future DateTime input to draw at.
          Oh ok. To draw at a future date, would that mean just using a negative index for the 'x' position in various draw methods to plot it forward of the last bar?

          Or do you literally mean as suggested, and use say for example using:

          Code:
          DrawLine(string tag, bool autoScale, DateTime startTime, double startY, DateTime endTime, double endY, Color color, DashStyle dashStyle, int width)
          As I would always want to start plotting at the bar that is one bar forward of the CurrentBar, which I'm not sure is particularly conducive to accepting a DateTime it seems?

          Comment


            #6
            Unfortunately using a negative index in the plots would not be supported by us - the most current bar is at 0, which is the rightmost bar...

            Correct, you would supply a future timestamp to draw at, which would be known for time based bar types.

            You know the time of the CurrentBar (Time[0]) so you can add 5 minutes to that if you're running a 5 min chart for example...

            Comment


              #7
              Ok, but just to be sure, can you think of any way to do it based on a bar index, instead of a time stamp.... so that it would easily be applied to chart types not based on time, such as CVB or range charts?

              Comment


                #8
                Unfortunately not, as you would not know here when the next bar would form - as those types exclude time...

                Comment


                  #9
                  It's not pretty but you can "guess" at what the time period(s) would be when using variable time periods.

                  Set up a DateTimeSeries. Subtract Time[0] from Time[1] and store the result in your DateTimeSeries. For a very conservative approach, take the MAX(DateTimeSeries,5) [0] and use this to calculate your forward time displacement for each future bar you need to draw.

                  This is not perfect but should work about 90% of the time. The problem is when real time approaches and then overtakes your future bar[s] before a new bar is added to the chart. When this happens, whatever Draw Object you use disappears from the chart.

                  Comment


                    #10
                    Well, I can kinda of project a bar forward using a negative index, which I suppose isn't supported, but might accomplish what I want. Using something like this:
                    Code:
                    DrawLine("tag1"+CurrentBar, false, -2,Low[0], -2, High[0], Color.Red, DashStyle.Solid, 2);
                    The question is, is it possible to erase certain objects? I.e. if I want to erase everything to the left of the most current bar, is that possible? Attached is a picture of all of the leftover bars on the chart, and I would like to erase everything to the left of the current bar, so that I would only be left with my forward projection.
                    Attached Files

                    Comment


                      #11
                      I think I got it, using +CurrentBar was making things difficult.

                      Comment


                        #12
                        Glad to hear, correct - it would then only modify / update the one / your last draw object (so without currentbar)

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        637 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        366 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        107 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        569 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        571 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X