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.
    Chris L.NinjaTrader Customer Service

    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.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ageeholdings, Today, 07:43 AM
      0 responses
      7 views
      0 likes
      Last Post ageeholdings  
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      12 views
      0 likes
      Last Post burtoninlondon  
      Working...
      X