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

Printing Margin for Draw.Text()

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

    Printing Margin for Draw.Text()

    Dear Support,

    Currently I use Draw.Text() to draw swing high/low information using a +/- margin based on either a multiple of TickSize or ATR() away from the swing high/low bar. However, this margin is dynamic and becomes inconsistent, either too large or too small depending on timeframe, volatility, instrument, etc. Here is my question:

    Is it possible to print swing information text (Vol, Points, etc.) with a constant margin that is static and will not change as the timeframe, volatility, or instrument is changed?

    I assume this could be done using a certain number of pixels away from the swing highs and lows. Any ideas how to accomplish this in Draw.Text()?

    Many thanks.

    #2
    Hello aligator,

    Thanks for your post.

    Draw.Text will allow us to place text at certain price levels. If you are trying to draw text a certain number of pixels away from a given point, this could be done with SharpDX rendering in OnRender. You could for example, use ChartScale.GetYByValue to get the Y coordinate of where you want to draw, and then you can add subtract pixels from that value to create the Y coordinate you want the text to reside.

    To get more acquainted with SharpDX rendering, please see the Help Guide article below, and please see the SampleCustomRender indicator that comes with NinjaTrader.

    https://ninjatrader.com/support/help..._rendering.htm

    ChartScale.GetYByValue - https://ninjatrader.com/de/support/h...etybyvalue.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello aligator,
      You can try yPixelOffset within Draw.Text(), I am attaching a snapshot of it for quick reference. If it doesn't work for yo then you might need a new one as suggested by Jim.
      Click image for larger version

Name:	draw text.jpg
Views:	390
Size:	26.8 KB
ID:	1125589
      Last edited by s.kinra; 10-31-2020, 01:05 AM.

      Comment


        #4
        Originally posted by NinjaTrader_Jim View Post
        Hello aligator,

        Thanks for your post.

        Draw.Text will allow us to place text at certain price levels. .
        Thanks Jim,

        I was trying to avoid SharpDX, if possible, since I had several indicators to fix and instead find a way to use a static vertical margin in Draw.Text(). This feature is already provided in Help section and I missed it. Although, at some point I have to transition to SharpDX for more options and efficiency.

        Thanks again.


        Originally posted by s.kinra View Post
        Hello aligator,

        You can try yPixelOffset within Draw.Text(), I am attaching a snapshot of it for quick reference. If it doesn't work for yo then you might need a new one as suggested by Jim.

        Click image for larger version  Name:	draw text.jpg Views:	0 Size:	26.8 KB ID:	1125589
        Thank you kinra,

        That works perfectly. The yPixelOffset syntax was already in Help Section as 1 of the 7 options for Draw.Text(), and I missed it.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by junkone, 04-21-2024, 07:17 AM
        10 responses
        148 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by tsantospinto, 04-12-2024, 07:04 PM
        6 responses
        100 views
        0 likes
        Last Post tsantospinto  
        Started by rocketman7, Today, 02:12 AM
        5 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by ZenCortexReal, Today, 08:54 AM
        0 responses
        1 view
        0 likes
        Last Post ZenCortexReal  
        Started by ZenCortexReal, Today, 08:52 AM
        0 responses
        0 views
        0 likes
        Last Post ZenCortexReal  
        Working...
        X