Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bmartz, 03-12-2024, 06:12 AM
      4 responses
      31 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by Aviram Y, Today, 05:29 AM
      4 responses
      12 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      28 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by gentlebenthebear, Today, 01:30 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by cls71, Today, 04:45 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X