Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Text: Fixed x position based on chart margin

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

    Draw Text: Fixed x position based on chart margin

    Hi, in NT7 I used graphics.DrawString() to draw a string at a specific location. The indicator would display the amount of contracts that was left in a tick. It would also follow price in the Y but had a fixed X position based on the chart property's margin.

    So far I have the NT8 indicator following price in the Y axis using Draw.Text() and Close[0]. However, the only two x positions I can choose is based on time or on the bars. Is there anyway to set it based on the the margin?

    Thank you
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Welcome to the forums Unsuitable!

    NinjaTrader 8 uses SharpDX for custom rendering and uses the OnRender() method for these purposes when NinjaTrader 7 uses GDI+ graphics and the Plot() method. You could use SharpDX to draw text at some defined coordinates on the chart, or you could consider using Draw.TextFixed. We include a SampleCustomRender example indicator with NinjaTrader 8 which describes how custom rendering can be done.

    Resource management is important to consider with SharpDX rendering as undisposed brushes and devise dependent SharpDX resources can cause memory leaks and rendering errors if not managed correctly. Please also see the ChartBars, ChartControl and ChartScale documentation for helper methods to convert data points and bar indexes to chart coordinates.

    Using SharpDX for custom rendering - https://ninjatrader.com/support/help..._rendering.htm

    SharpDX reference - https://ninjatrader.com/support/help..._reference.htm

    ChartBars - https://ninjatrader.com/support/help.../chartbars.htm

    ChartControl - https://ninjatrader.com/support/help...artcontrol.htm

    ChartScale - https://ninjatrader.com/support/help...chartscale.htm

    Draw.TextFixed - https://ninjatrader.com/support/help..._textfixed.htm

    If you have any additional questions, please do not hesitate to ask.

    Comment


      #3
      Well I got to the point where I have a SharpDX vector that uses price and chartControl margin. How do I draw text that is fixed to that vector?
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment


        #4
        Hello Unsuitable,

        I have attached a conversion of a NinjaTrader 7 script that uses DrawString which may offer additional direction.

        Please let me know if I can be of further assistance.
        Attached Files

        Comment

        Latest Posts

        Collapse

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