Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IText.BarsAgo

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

    IText.BarsAgo

    In NT7 IText had a property BarsAgo. Is there a replacement for it with the new Text class?

    #2
    All draw objects will have some sort of "ChartAnchor" field which exposes this information, rather than a field directly on the interface/object itself.
    e.g.,
    Code:
    Text myText = Draw.Text(this, "tag", "test", 0, High[0]);
    Print(myText.Anchor.BarsAgo); // the barsAgo value passed to the method
    Print(myText.Anchor.DrawnOnBar); // the actual current bar
    MatthewNinjaTrader Product Management

    Comment


      #3
      I meant to also mention that the implementation of barsAgo has changed, if you need the number of actual bars that have passed since the current bar, you need to calculated that from .DrawnOnBar

      Code:
      Print(CurrentBar - myText.Anchor.DrawnOnBar);
      MatthewNinjaTrader Product Management

      Comment


        #4
        Hi Matthew,
        I use to be able to just set the BarsAgo property (say to -1) on a Text object to get it to move to the end of the chart on the x-axis after every new bar. I assumed this was more efficient than deleting the old one and creating a new one. How would I do that with the new drawing objects?

        Comment


          #5
          Hello,

          Probably the most efficient way to go about this would be to simply redraw the text. You could call Draw.TextFixed() once more, using the same tag as the previously drawn text, to overwrite the existing instance with a new position.
          Dave I.NinjaTrader Product Management

          Comment


            #6
            Originally posted by GrumpyTrader View Post
            Hi Matthew,
            I use to be able to just set the BarsAgo property (say to -1) on a Text object to get it to move to the end of the chart on the x-axis after every new bar. I assumed this was more efficient than deleting the old one and creating a new one. How would I do that with the new drawing objects?
            Hmm, works here...

            Draw.Dot(this, "tag", false, -1, High[0], Brushes.Blue);

            What chart setup, method, indicator settings, etc are you using?

            What is it currently doing instead of moving to the next bar?
            MatthewNinjaTrader Product Management

            Comment


              #7
              If you meant on the IDrawingTool object, you can use the Time[0] property

              Code:
              		protected override void OnBarUpdate()
              		{			
              		  if(State.Historical == State)
              			 myText = Draw.Text(this, "tag", "Test", 5, High[0], Brushes.Blue);
              			
              		  else if(myText != null)
              			myText.Anchor.Time = Time[0];
              			
              		}
              MatthewNinjaTrader Product Management

              Comment


                #8
                Thanks, setting the time works perfectly. Lastly, I'm not sure if it is a bug, but for some reason when using the Ray object the intellisense doesn't show you the Tag property even though it is there.

                Comment


                  #9
                  Hi GrumpyTrader,

                  I was able to confirm that Tag is not in the intellisense list for IDrawingTools.

                  You can use this, and it will compile if you do, but its not in the list.

                  I appreciate you reporting this issue.

                  I have submitted a bug report about this to development. Please let me know if you find any other issues in NT8 you would like to report.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pvincent, 06-23-2022, 12:53 PM
                  14 responses
                  238 views
                  0 likes
                  Last Post Nyman
                  by Nyman
                   
                  Started by TraderG23, 12-08-2023, 07:56 AM
                  9 responses
                  383 views
                  1 like
                  Last Post Gavini
                  by Gavini
                   
                  Started by oviejo, Today, 12:28 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post oviejo
                  by oviejo
                   
                  Started by pechtri, 06-22-2023, 02:31 AM
                  10 responses
                  125 views
                  0 likes
                  Last Post Leeroy_Jenkins  
                  Started by judysamnt7, 03-13-2023, 09:11 AM
                  4 responses
                  59 views
                  0 likes
                  Last Post DynamicTest  
                  Working...
                  X