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 Balage0922, Today, 07:38 AM
      0 responses
      1 view
      0 likes
      Last Post Balage0922  
      Started by JoMoon2024, Today, 06:56 AM
      0 responses
      6 views
      0 likes
      Last Post JoMoon2024  
      Started by Haiasi, 04-25-2024, 06:53 PM
      2 responses
      19 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      6 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Working...
      X