Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Placing Labels Next to Each Other on a Chart

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

    Placing Labels Next to Each Other on a Chart

    Dear NT Indicator Forum,

    I'm trying to work out how to draw labels next to each other on a chart. To clarify my request, let's say I have 3 indicators on my chart - a MACD, a Stochastic and an ATR. I would like to display 3 labels on my chart: ATR(8): <ATR value> MACD: Trend Up Stoch: Trend Up

    How would I accomplish this? To display a single label, I use the Draw,TextFixed method which offers predefined locations on the chart. I did a little research and there's also Draw.Text which offers more flexibility, but I'm not sure how to use this.

    When using labels in Thinkorswim, the platform recognizes multiple labels and automatically displays them one after another (see photo attached). No additional programming required. How would I get the equivalent functionality in NT8?

    One way I can think of is to code a single indicator and embed all 3 indicators into this custom indicator, and concatenate the string value for all 3 labels - I feel that's just improper and brute-force coding. There must be a better, more elegant way to do this.

    Thanks!
    Attached Files
    Last edited by aguison; 06-19-2024, 02:45 PM.

    #2
    Hello aguison,

    Labels like that would require using Draw.TextFixed which can't offset or know about other fixed texts meaning they will overlap or using OnRender which would require using X/Y positioning. For separate indicators there would not be a good way to accomplish that because the indicators won't know what other indicators are applied and may calculate in different orders, there wouldn't be an easy way to offset the labels. A single script could accomplish this and offset all the labels it creates because it would be able to keep track of what has been drawn already. A single script can use Draw.TextFixed and make multiple vertical texts by using the newline character \n after each part you want on a new line. OnRender could be used to create what you have in the image which would offset the next rendering by X amount based on the texts width.

    Comment


      #3
      Thanks Jesse. There are two OnRender methods - one is OnRender (Chartstyle) and the other is OnRender (Rendering). I assume you're talking about the second one? Do you have any sample code you can give out to get an idea of how to use it? Thanks
      Last edited by aguison; 06-20-2024, 06:09 AM.

      Comment


        #4
        Hello aguison, OnRender is the same for all types of objects so the area where you found the information in the help guide is not necessarily relevant, the concepts of rendering something to the chart would be the same and many NinjaScript types use OnRender. You can find a sample of drawing text and other items from an indicator by looking at the SampleCustomRender script that comes with NinjaTrader.

        Comment


          #5
          Maybe make a 'display' indicator that takes output of other indicators and renders them on the chart.

          Comment


            #6
            Thanks Mice1999 - yes, that is one way Jesse was suggesting

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            599 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            345 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            558 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            558 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X