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

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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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...
            BertrandNinjaTrader Customer Service

            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...
                BertrandNinjaTrader Customer Service

                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)
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by AttiM, 02-14-2024, 05:20 PM
                        11 responses
                        184 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by fernandobr, Today, 09:11 AM
                        1 response
                        3 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Started by timmbbo, Today, 08:59 AM
                        1 response
                        3 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by KennyK, 05-29-2017, 02:02 AM
                        2 responses
                        1,281 views
                        0 likes
                        Last Post marcus2300  
                        Started by itrader46, Today, 09:04 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Working...
                        X