Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time/Date Stamp of Firstbar loaded

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

    Time/Date Stamp of Firstbar loaded

    Hello There

    I seem to be using alot if time troubleshooting missing data errors. because i run in differant time frames,
    bars required on a 30 sec series would be alot higher than on a daily series.


    Instead of defining Bars required in numbers of bars the traditinal way i want to define it in a matter of hours.
    how can i get the time / data stamp of the first bar recieved ?

    I will then check that with the current bar and check i always have atleast for an example 48 hours in between.

    I was hoping to do something like this but cant seem to get it working.

    if (Time[CurrentBars[0]].AddHours(48) >= Time[b])
    return;​
    Last edited by donto; 12-21-2024, 03:49 AM.
    Donto
    NinjaTrader Ecosystem Vendor - otrading.dk

    #2
    Maybe use:

    if(CurrentBar == 1)
    .....



    and also do a forum search for "IsFirstBarOfSession" , which may be of use...

    Comment


      #3
      Hello donto,

      Time[CurrentBars[0]] would provide the time of the first bar of the primary series.

      I would recommend using prints to understand the behavior.


      Print(string.Format("{0} | BarsInProgress: {1} | Time[CurrentBars[0]: {2}]: {3} .AddHours(48): {4} => Time[b: {5}]: {6}", Time[0], BarsInProgress, Time[CurrentBars[0]], Time[CurrentBars[0]].AddHours(48), b, Time[b]));

      You can use Bars.GetBar() to get a bar with an absolute index for a given datetime, and subtract this from CurrentBar for a barsAgo index.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 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