Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Start time

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

    Bar Start time

    I see that I can use Time[0] to get the current bar end time. Is there a direct way to get the bar start time as well from inside OnBarUpdate?

    #2
    Hello swooke,

    Thanks for your post.

    You could use Calculate.OnEachTick and then check DateTime.Now on IsFirstTickOfBar which will tell you the time of the tick that opened the bar.

    This would only work for realtime data and would not be relevant for backtesting. If you want a backtestable solution, I recommend adding a single tick data series and checking the timestamp of the tick that occurs just after the bar closure for the primary bar is seen.

    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    Please let me know if there is anything else we can do to help.

    Comment


      #3
      Thanks Jim,

      Just one other quick question. How can I get the distance between each candle body? For example, in the screencast link below, I pointed to the gap with a red arrow. I tried BarMarginLeft but that always returns 8 pixels. Here is the screenshot:
      World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.

      Comment


        #4
        Hello swooke.

        Thanks for the question.

        I believe you are looking for ChartControl.Properties.BarDistance.



        Please let me know if there is anything else we can do to help.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        80 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X