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

Can not get DrawText to work (NT6)

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

    Can not get DrawText to work (NT6)

    I created an indicator using wizard without changing anything.

    The only line of code that I have in OnBarUpdate()is

    DrawText(
    "TEST", "TEST1", 5, Close[1], Color.Black);

    However, nothing is being displayed on the chart. I am obviously doing something wrong.

    Thanks,

    redduke

    #2
    imported post

    Please inspect your logs. NT reports issues to the logs. It's always a good idea to check there first. There likely will be an error message

    Error on calling the 'OnBarUpdate' method for indicator 'MyCustomIndicator' on bar 1: Bar index needs to be greater/equal 0

    You need to code:
    Code:
       if (CurrentBar >= 5)
        DrawText("TEST", "TEST1", 5, Close[1], Color.Black);
    Reason: You are trying to access a bar 5 bars ago which is not yet there as the indicator processes e.g. bar 1.

    We will look into making this more tolerant...

    Comment


      #3
      imported post

      Dierk, Thanks a lot.






      Comment


        #4
        imported post

        Hi Dierk,

        Is there anyway to increase the size of the font?

        Thanks

        Comment


          #5
          imported post

          Not programmatically. You can change the properties of an existing text object and save them as default.

          Comment


            #6
            imported post

            Dierk,

            The logic that I have constanly removes and then draws the values. I need to remove them because otherwise the charts will be too clogged. So, even if I change the text object settings and increase the font, it obviously dissapears once it removed and drawn again. Any other way of increasing it?

            Thanks,

            redduke


            Comment


              #7
              imported post

              Apart from setting and saving the default font size? Sorry no.

              Comment


                #8
                We just were able to figure this one out.

                This line creates font object:

                Font fnt = new Font (FontFamily.GenericSansSerif, 14.0F,
                FontStyle.Bold);

                Now, it can be used in drawing (string cnt needs to be filled with value):

                DrawText("counter", cnt, 1, High[1]+2, Color.Blue, fnt,
                StringAlignment.Center, Color.DarkSeaGreen, Color.DarkSeaGreen, 10);

                Regards,
                redduke

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Christopher_R, Today, 12:29 AM
                0 responses
                6 views
                0 likes
                Last Post Christopher_R  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                166 responses
                2,235 views
                0 likes
                Last Post sidlercom80  
                Started by thread, Yesterday, 11:58 PM
                0 responses
                3 views
                0 likes
                Last Post thread
                by thread
                 
                Started by jclose, Yesterday, 09:37 PM
                0 responses
                7 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,415 views
                0 likes
                Last Post Traderontheroad  
                Working...
                X