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 LawrenHom, Today, 10:45 PM
      0 responses
      3 views
      0 likes
      Last Post LawrenHom  
      Started by love2code2trade, Yesterday, 01:45 PM
      4 responses
      28 views
      0 likes
      Last Post love2code2trade  
      Started by funk10101, Today, 09:43 PM
      0 responses
      7 views
      0 likes
      Last Post funk10101  
      Started by pkefal, 04-11-2024, 07:39 AM
      11 responses
      37 views
      0 likes
      Last Post jeronymite  
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      44 views
      0 likes
      Last Post bill2023  
      Working...
      X