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

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 Gerik, Today, 09:40 AM
            2 responses
            7 views
            0 likes
            Last Post Gerik
            by Gerik
             
            Started by RookieTrader, Today, 09:37 AM
            2 responses
            11 views
            0 likes
            Last Post RookieTrader  
            Started by alifarahani, Today, 09:40 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by KennyK, 05-29-2017, 02:02 AM
            3 responses
            1,285 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by AttiM, 02-14-2024, 05:20 PM
            11 responses
            186 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X