• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add text on bar

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

    Add text on bar

    Hi,
    I am using the method Draw.Text to have some text on top of a certain bar if some conditions are met. I would like to add on top of that text (on the same bar) some other text if some other conditions are also verified. If I use the same tag the existing text will be simply replaced with the new one. If I use a different tag the two texts will be overlapped.

    Is there any automatic way to recognize if on top of a bar there is already some text and add the new text above?

    Thank you.

    #2
    Hello Apeppo,

    Thanks for your post and welcome to the NinjaTrader forums!

    No, there is no means to automatically know if there is text above the bar.

    As your script is drawing the initial text you should be able to create logic to handle this. You could use a bool variable to indicate that the initial text had been drawn. For example:

    if (your conditions to draw initial text on the bar)
    {
    DrawText(...above the bar);
    textDrawn = true; // set a bool variable to true indicating initial text drawn
    }

    if (some other conditions to also draw text)
    {
    if (textDrawn)
    {
    DrawText(...above the previous text);
    else
    DrawText(...above the bar);
    }

    If you are using looping to go back and add text above a bar then another approach would be to create a bool data series that has the same elements as the data series so you can assign a true/false value relative to the bar number which then allows you to test that data series for a given bar. Reference: https://ninjatrader.com/support/help...ries_class.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi PaulH,

      thank you for your reply.

      I understand your point but it could be that I have to draw more than two texts (one above the other). So, in this case I need to create a bool data series for the first text level, another one for the second one and so on...

      Anyway, I need to know how many texts have been drawn on top of bar to be able to not "hide" the new text. I will implement some logic to do that.

      Comment


        #4
        Hello Apeppo,

        Thanks for your reply.

        Just to let you know, another option would be to use an integer data series that you can increment in value for each text you place above the bar. Reference: https://ninjatrader.com/support/help...ries_class.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello PaulH,

          yes, this is even better!

          Thank you for your reply and time.

          Comment


            #6
            Faced the same problem. Thanks for the information.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TikDaddy, Today, 02:08 PM
            2 responses
            8 views
            0 likes
            Last Post NinjaTrader_JoshG  
            Started by Brillo, Today, 01:52 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by TazoTodua, 02-09-2018, 08:40 AM
            10 responses
            880 views
            0 likes
            Last Post NinjaTrader_JoshG  
            Started by TazoTodua, Yesterday, 04:35 AM
            6 responses
            18 views
            0 likes
            Last Post eDanny
            by eDanny
             
            Started by MattP, Today, 12:25 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Working...
            X