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

InfoBox example for drawing text

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

    InfoBox example for drawing text

    I would like to create an indicator that draws some text in a box. Some of the text will be bold and some not. For example:

    Symbol | Last
    SPY $325.02
    AAPL $450.04
    INTC 125.63

    I am familiar with Draw.TextFixed but wasn't sure if that was the right approach or not. Is there an example that best demonstrates something like this and how it would be approached? Thanks,

    #2
    Hello swcooke,

    Thanks for your post.

    Likely the best approach would be to use OnRender and draw the box and text as you wish. There is no specific example that matches what you are asking for but you can see an example of the coding required in the indicator "SampleCustomRender".

    If you can do without the box, then I would suggest the simpler Draw.TextFixed(). I've attached an example that shows the OHLC values of the bar in the upper right corner. The example is to show how to stack the information as well as color it. In your case though you would likely need to create two fonts, one bold and the other not, but the example may get you going.

    DrawTextFixedColorExample.zip
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thanks Paul. That should work. I'll just use CustomRender to draw the box under the text drawn with DrawTextFixed. Does that sound right? Also, if it's not too difficult, could you tell me how to modify the text below so that it's bold? Been trying for about 2 hours. Sorry, it's a little new for me.

      Code:
      Draw.TextFixed (this, "testa", "Open:\t\t", TextPosition.TopRight, axisColor, chartFont, Brushes.Transparent, Brushes.Red, 0);

      Comment


        #4
        Hello swcooke,

        Thanks for your reply and glad you found example that of use.

        To get the font to be bold you will need to add another simpleFont where the bold is set true. Please see the help guide which shows an example of bold.


        In the Draw text that you want bold you would use that simplefont.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        4 responses
        31 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X