• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 ct, Today, 08:13 PM
      0 responses
      3 views
      0 likes
      Last Post ct
      by ct
       
      Started by Lumbeezl, Today, 05:17 PM
      0 responses
      6 views
      0 likes
      Last Post Lumbeezl  
      Started by wishing, Today, 03:33 PM
      0 responses
      10 views
      0 likes
      Last Post wishing
      by wishing
       
      Started by ATMtrader0001, Today, 01:48 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by RandanAL, Yesterday, 05:13 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Kate  
      Working...
      X