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

Finding the pixel distance between 2 bars

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

    Finding the pixel distance between 2 bars

    Is there a way to transform the distance between bars (or time) to chart pixels?

    I have 2 vertical bars I draw, and I would like them to be one next to the other. I use the time to set their position, but when the chart is scaled, they may be too close or too far. I am looking for a way to calculate the difference I would like to set them up according to the X scale.

    Assuming this can be done, I would need to force an update of only this calculation. My guess I need to get this information from onRender and save the last value.

    By the way, I am not drawing using onRender(). Instead, I do all my drawing from onBarUpdate().

    #2
    Hello Shai Samuel,

    Thanks for your post.

    ChartControl.Properties.BarDistance will give the pixel distance between bars. Using Drawing Tools in OnBarUpdate() will draw by bar slots and cannot be placed at specific pixel locations. If you would like to draw at specific pixel locations, OnRender() should be used with your own SharpDX rendering. Our SampleCustomRender example indicator can be used as reference for using OnRender, and I have also included resources on using SharpDX for custom rendering. Pixels will be relevant to the ChartPanel owned by the indicator.

    ChartControl.Properties - https://ninjatrader.com/support/help...properties.htm

    SharpDX Rendering - https://ninjatrader.com/support/help..._rendering.htm

    Chart Panel - https://ninjatrader.com/support/help...chartpanel.htm

    Please let us know if there is anything else we can do to help.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    160 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    9 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X