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 Haiasi, 04-25-2024, 06:53 PM
    2 responses
    17 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    5 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,407 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Working...
    X