Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Range indicators

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

    Range indicators

    Ninjatrader 7, please is there any reference to
    1.'day', 'Previous day' previous time'.

    Placing into code or programming ;
    2. if OpenPrice > 10 at 12.00 and price < previous day high.

    thank you.

    #2
    Hello,

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.

    Comment


      #3
      Hello,

      Thank you for the note.

      You may use GetDayBar() to access any previous day.

      You may select which data you want from that day.

      For example:

      Code:
      Bars.GetDayBar(int tradingDaysBack).Open
      Bars.GetDayBar(int tradingDaysBack).High
      Bars.GetDayBar(int tradingDaysBack).Low
      Bars.GetDayBar(int tradingDaysBack).Close
      If I wanted the close from yesterday I would do:

      Code:
      protected override void OnBarUpdate()
      {
        // Check to ensure that sufficient intraday data was supplied
        if(Bars.GetDayBar(1) != null)
          Print("The prior trading day's close is: " + Bars.GetDayBar(1).Close);
      }
      More on GetDayBar() here:


      To access a bar at a specific time use GetBar()

      More on GetBar() here:


      This method takes a DateTime object so if you wanted the bar at 12:00PM today you would do something like this:

      Code:
      // Calculate the bars ago value for the 12 PM bar for the current day
        int barsAgo = CurrentBar - Bars.GetBar(new DateTime(2017, 7, 3, 12, 0, 0));
       
        // Print out the 12 PM bar closing price
        Print("The close price on the 12 PM bar was: " + Close[barsAgo].ToString());
      Here is a publicly available link on the DateTime contructor:
      Represents an instant in time, typically expressed as a date and time of day.


      For question 2,

      if OpenPrice > 10 at 12.00 and price < previous day high.

      Code:
      // Calculate the bars ago value for the 12 PM bar for the current day
        int barsAgo = CurrentBar - Bars.GetBar(new DateTime(2017, 7, 3, 12, 0, 0));
       
        if(Open[barsAgo] > 10 && Close[0] < Bars.GetDayBar(1).High);
      Please let me know if I may be of any further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      65 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      41 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      23 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      26 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      52 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X