Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting the highs and lows of current session, RTH and AH

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

    Getting the highs and lows of current session, RTH and AH

    Hi,

    I'm attempting to acquire the high and low of the day and use those data points as a variable to take action from. I came across a post with a sample and this is working fine for the high, but is way off for the low. The low of the day right now is 3808 and it is showing 3657 so it's got to be going all the way back to Sunday open for that. The instrument I'm using is /MES.

    Code:
    //return high and low of RTH session
    if (regularTradingHours)
    {
    if (Bars.IsFirstBarOfSession)
    {
    Print("Calculating trading day for " + Time[0]);
    // use the current bar time to calculate the next session
    sessionIterator.GetNextSession(Time[0], true);
    
    // store the desired session information
    beginTime = sessionIterator.ActualSessionBegin;
    }
    
    var startBarsAgo = Bars.GetBar(beginTime);
    Print("startBarsAgo = " + startBarsAgo);
    double highestHigh = MAX(High, CurrentBar - startBarsAgo + 1)[0];
    
    // Now that we have the start and end bars ago values for the specified time range we can calculate the lowest low for this range
    var lowestLow = MIN(Low, CurrentBar - startBarsAgo + 1)[0];
    // Set the plot values
    HighestHigh[0] = highestHigh;
    LowestLow[0] = lowestLow;
    Draw.TextFixed(this, "highLowText", HighestHigh[0] + " High | " + LowestLow[0] + " Low", TextPosition.TopLeft);
    
    HighestHigh[0] = HighestHigh[1];
    LowestLow[0] = LowestLow[1];
    }
    So this kind of works, but something is off here and it doesn't work during AH.

    Hoping for some guidance or a working example as I'm having a difficult time figuring this one out.


    Thanks!

    #2
    Hello DogEars, thanks for your post.

    The CurrentDatOHL indicator will provide daily OHL for the bar series you give to it. The primary series of the script can be the ETH template and you can add an RTH data series using this AddDataSeries overload:
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)

    You can then set up two CurrentDayOHL indicators in the script. One will take the primary series and the other will take the secondary series e.g.
    CurrentDayOHL(BarsArray[0]);
    CurrentDayOHL(BarsArray[1]);

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks, I missed that one. I'll check it out and see how it goes.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by t.kelly4149, Today, 05:36 PM
      1 response
      5 views
      0 likes
      Last Post bltdavid  
      Started by SilverSurfer1, Today, 06:29 PM
      0 responses
      14 views
      0 likes
      Last Post SilverSurfer1  
      Started by trader3000a, Today, 01:06 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by marcus2300, Today, 11:45 AM
      3 responses
      30 views
      0 likes
      Last Post marcus2300  
      Started by pel11, Today, 11:06 AM
      0 responses
      12 views
      0 likes
      Last Post pel11
      by pel11
       
      Working...
      X