Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting a Line in the future

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

    Plotting a Line in the future

    Having now switched to NT8, and read what I think is the appropriate documentation for DataSeries and related classes, I cannot determine whether it is possible to programmatically plot a line that represents the future on a chart. The use case is basically plot a forecast for the trading day (more generally, trading period) at the beginning of the period. Then as the period progresses in real time, the real time line (bars) would "catch up" with the forecast. The values in the forecast would have the same time period as real time (i.e., if the real time chart was plotting 2-minute bars, the forecast would have a point for every 2-minute period in the future until the end of the trading period).

    So my question is simply, is this possible in NT 8?
    Thanks.

    #2
    Originally posted by TurtleBeach View Post
    Having now switched to NT8, and read what I think is the appropriate documentation for DataSeries and related classes, I cannot determine whether it is possible to programmatically plot a line that represents the future on a chart. The use case is basically plot a forecast for the trading day (more generally, trading period) at the beginning of the period. Then as the period progresses in real time, the real time line (bars) would "catch up" with the forecast. The values in the forecast would have the same time period as real time (i.e., if the real time chart was plotting 2-minute bars, the forecast would have a point for every 2-minute period in the future until the end of the trading period).

    So my question is simply, is this possible in NT 8?
    Thanks.
    Yes. Depending on the mechanics that you have not explained, you can displace an indicator's Plots into the future or you can read up on Draw.<Object> methods: specifically, probably, Draw.Line() and Draw.Dot(), might be the most apposite.
    Last edited by koganam; 12-22-2015, 03:56 PM.

    Comment


      #3
      Koganam is correct, and I'll add that using a negative number as your Bars Ago value is the key to drawing an object in the future:

      Code:
      Draw.Line(this, "line", 5, Low[5], -5, 2064, Brushes.Green);
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Originally posted by NinjaTrader_Dave View Post
        Koganam is correct, and I'll add that using a negative number as your Bars Ago value is the key to drawing an object in the future:

        Code:
        Draw.Line(this, "line", 5, Low[5], -5, 2064, Brushes.Green);
        Hi Dave,

        Having asked this related old question before and no clear answer yet.

        Is it possible to draw future time-based events such as calendar events (using date.time instead of bar numbers). For example, I want to DrawText at 10:30 A.M. Wed next week as a reminder for Oil report or at 5:30 A.M. on Friday of the next week for Non Farm Report? If so, How?

        Let's say I am watching a 5M chart at 5:15 AM and I will be able to see the reminder ahead of time. The idea is to import the ForexFactory's calendar for next week on a chart and be able to scroll through that in future time, and when that event is passed it remains on historic bars.

        Thanks.
        Last edited by aligator; 01-30-2016, 09:21 PM.

        Comment


          #5
          In light of Koganam's suggestions I ended up using DrawLine, with DateTime values to plot both arbitrary lines in the future, and to position text boxes at various points, also using DateTime values. It is probably necessary for DateTime values to be consistent with bar size (i.e., if bars are 2 minute, time values should be 00:02, 00:04 etc.). I haven't checked this - I just made my time stamps consistent with bars size, and that seems to work. It strikes me this is probably not the most efficient approach, but in my case it doesn't matter since the lines are plotted once a day. And after the lines/text boxes are on a chart, resizing the chart seems to automatically handle the lines/text boxes as expected (or at least hoped for).
          Jack

          Comment


            #6
            Originally posted by TurtleBeach View Post
            In light of Koganam's suggestions I ended up using DrawLine, with DateTime values to plot both arbitrary lines in the future, and to position text boxes at various points, also using DateTime values. It is probably necessary for DateTime values to be consistent with bar size (i.e., if bars are 2 minute, time values should be 00:02, 00:04 etc.). I haven't checked this - I just made my time stamps consistent with bars size, and that seems to work. It strikes me this is probably not the most efficient approach, but in my case it doesn't matter since the lines are plotted once a day. And after the lines/text boxes are on a chart, resizing the chart seems to automatically handle the lines/text boxes as expected (or at least hoped for).
            Jack
            Thanks Jack.

            I think if minute data is available future plots of multiple minutes is possible.
            Would you mind sharing your code for drawing a date.time-based line in the Future?

            Thanks.

            Comment


              #7
              Here is the line code (executed in a loop):

              Code:
               
               [FONT=Courier New]Draw.Line( this, tag1, autoScale,[/FONT]
               [FONT=Courier New]           prior, firstPoint,[/FONT]
               [FONT=Courier New]           future, finalPoint,[/FONT]
               [FONT=Courier New]           Brushes.Aqua, DashStyleHelper.Solid,[/FONT]
               [FONT=Courier New]           stdLineWidth, usePricePanel);[/FONT]
              prior and future are DateTime variables initialized to an even minute (e.g., 8:00 on the current day).
              tag1 is a string variable that gets updated in the loop to provide a unique tag (basically an integer is appended to a base string).
              firstPoint and finalPoint are the values to plot and are also updated (from a previously generated array); at the bottom of the loop the new firstPoint is the old finalPoint.
              usePricePanel is a Boolean that is usually false

              Here is the text code (executed periodically in OnBarUpdate:
              Code:
               
               [FONT=Courier New]Draw.Text(this, "TotDirCMC", false,[/FONT]
               [FONT=Courier New]          string.Format("Dir CMC {0:F6}", CMCDirect),[/FONT]
               [FONT=Courier New]          firstDataTime, [/FONT][FONT=Courier New]directY,[/FONT]
               [FONT=Courier New]          2, DirectBrush, displayFont,[/FONT]
               [FONT=Courier New]          TextAlignment.Right, Brushes.Black,[/FONT]
               [FONT=Courier New]          DirectBackground, 75);[/FONT]
              firstDataTime is calculated when needed but is always at a 2-minute time slot (since I am using 2 minute bars for realtime data).
              Jack

              Comment


                #8
                @NinjaTrader_Dave, or Support

                A related question: As noted in release notes, Beta 9 changed Anchor point reference from Bar number to Time stamp. Does this mean if drawing an object in the future it will now use time points instead of a negative bar number in the future for X axis?

                If so, it brings an old questions (asked several times before that Ninja Support has not answered yet).

                1. The x axis now shows both date and time in the future. However, the cross hair when moved in the future still freezes on the time for the current bar. For example, If I draw a vertical line in the future and I move the cross hair to that location it will not show the associated future time or date for that line.

                Comment


                  #9
                  Originally posted by aligator View Post
                  @NinjaTrader_Dave, or Support

                  A related question: As noted in release notes, Beta 9 changed Anchor point reference from Bar number to Time stamp. Does this mean if drawing an object in the future it will now use time points instead of a negative bar number in the future for X axis?
                  The drawing tool chart anchor has always and still uses a time value. This has not changed. The release notes just change how a drawing object is created when you call a drawing tool from NinjaScript. If you tried to draw using NinjaScript using a negative bar index currently, the object would be "clamped" to the current bar. Our development team is researching ways that we can re-implement some method of drawing NS objects in the future, but it's currently undecided (NTEIGHT-9404)

                  Originally posted by aligator View Post
                  @NinjaTrader_Dave, or Support

                  1. The x axis now shows both date and time in the future. However, the cross hair when moved in the future still freezes on the time for the current bar. For example, If I draw a vertical line in the future and I move the cross hair to that location it will not show the associated future time or date for that line.
                  The chart anchors/ axis always shows date time time in the future and has not changed. The release notes item mentioned is not related to your question, but to answer your question:

                  Default charts behavior is Equidistance bar spacing. This method will make sure that every single bar is spaced by an equal amount of pixels. This does not provide any sort of reliable way to give you a bar "slot" in the future, which means that your crosshair axis will stop at the last bar.

                  If you rather uncheck "Equidistant bar spacing" from the chart properties, the bars are now spaced by time, instead of by distance. This now allows us to add a slot in the future for times, and thus your cross hair will operate ahead of the last bar of the chart. (although this gets very tricky with tick and other non-time based charts, and these slots can change as new bars are added.).
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    future draw object on volume charts

                    So if all objects are to be drawn using date/time based anchor, then even though in the X axis you estimate what future bar date / time values will be they will most likely be incorrect. So what is the suggested method of drawing objects in the future, so they do not "move" as the actual bar / date time becomes more current / historical (actual).

                    John

                    Comment


                      #11
                      Originally posted by joromero View Post
                      So what is the suggested method of drawing objects in the future, so they do not "move" as the actual bar / date time becomes more current / historical (actual).
                      There is no way to do that. It's just not possible with non time based bars estimate where they will arrive in the future. Any draw objects on volume based bars will move as the actual bar comes in.
                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Exactly the issue, For any of the bar types that are not time based, there is no way to draw objects into the future. I do realize the challenge for you (Ninja) to architect a solution, considering -- if I save a chart non time based that has objects in the future, there is no date / time to associate them with. Maybe you need to save some additional data items like bars into the future from a know bar # / date time. With so many now looking at tick, Volume, Range, etc charts, I would think this should carry some weight.

                        John

                        Comment


                          #13
                          This is simply unacceptable. There should never be a reason to remove features that have been present in the past. There are multitudes of reasons to draw objects to the right of the current bar, even a simple text data box at price.
                          eDanny
                          NinjaTrader Ecosystem Vendor - Integrity Traders

                          Comment


                            #14
                            Hello eDanny,

                            It is currently being discussed on returning this feature in the next version of the beta.
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks, I did have a talk with Brett and this issue was brought up.
                              eDanny
                              NinjaTrader Ecosystem Vendor - Integrity Traders

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              14 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Yesterday, 07:51 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,983 views
                              3 likes
                              Last Post jhudas88  
                              Working...
                              X