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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    57 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    19 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    9 views
    0 likes
    Last Post cre8able  
    Working...
    X