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

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.
    JimNinjaTrader Customer Service

    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
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        17 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        7 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        9 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X