Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I must be missing something obvious

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

    I must be missing something obvious

    I have the following simple function in my strat:
    privateint GetBarsAgoIdx(DateTime dt)
    {
    int rc = CurrentBar - Bars.GetBar(dt);
    return rc;
    }

    Pretty simple.

    I have a chart with my strat dropped on it and this function get's called with the following info taken from the immediate window in
    vstudio.

    ?dt.ToString()
    "8/26/2016 2:32:20 PM"
    ?Bars.GetBar(dt);
    282114
    ?CurrentBar
    3

    This means I get a -282111. How is this possible? I'm running 4-Range on ES. No way there's 300,000 bars since Friday. What on earth am I missing?
    Thanks ... Ed


    #2
    Hello edstaffin,

    Thank you for writing in.

    Can you please confirm the time frame settings that you have in your Data Series window?

    To do this, right-click on the chart and select Data Series.

    Additionally, have you added any additional series to your script?
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Do you mean 4-Range (I mentioned this in my first post)? And no, no additional data series.
      Additionally, I found that CurrentBar == 3, Bars.Count == 282322, High.Count == Bars.Count, but if I try to access High[> 3] it barfs. I should also point out that this code works perfectly on a back test but falls short on an optimization.
      One last thing, I'm running it from 7/31/2014 forward.
      Thanks ... Ed
      Last edited by edstaffin; 08-30-2016, 03:49 PM.

      Comment


        #4
        Hello edstaffin,

        We will continue this through email.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          NT uses a proprietary integer based date/time. Do you possibly need to use ToTime() to convert your windows style date / time value?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          650 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X