Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Opening price

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

    Opening price

    Not sure if this has been done before by someone, also not sure how to search through 154 pages of general programming, to see if it has. Search topic, tag......
    Anyhow, I want to write some code that would go back a specified period of time, 2 months, 3, 6?, and gather the data from the close of the 2 minute bar.
    I want to know what the opening price is, what the closing price is of that 2 minute bar and if the close is above or below that bar. Maybe by writing 'above' or 'below' next to the data.
    I'd like to save this data to a file on my hard drive so I can look at it.
    Anyone aware of something like this being written or close to it?

    #2
    Hello dj0903,

    I am not aware of this code already written, but this is possible to do.

    With Bars.GetBar() you can supply a date and time and this will return the bar number for that bar.

    Using the bar number you can get any information from that bar you would like.

    For example:

    Print(Close[CurrentBar - Bars.GetBar(new DateTime(2015, 8, 28, 9, 0, 0))]);

    This would print the close price of the 9:00 bar from friday august 28th.


    You can compare this to the current price using something similar to:

    if (Close[0] > Close[CurrentBar - Bars.GetBar(new DateTime(2015, 8, 28, 9, 0, 0))])
    {
    Print(Time[0]+" current bar greater than bar from 8/28 at 9:00");
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Opening price

      Thanks Chelsea, I appreciate it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X