Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get # of Sessions

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

  • elitetradernyc
    replied
    Thanks, I was adding an array to store all the previous values and that really slowed down my backtests, perhaps ill try doing it another way.

    Leave a comment:


  • koganam
    replied
    Originally posted by elitetradernyc View Post
    Thanks, one other question, I want to get the close of two sessions ago, like PriorDayOHLC().PriorClose[x] but how do you get it to look back two sessions and not just 1?

    Thanks
    You merely need to make sure that your reference bar is the day before.
    Code:
    PriorDayOHLC().PriorClose[GetBar(Time[0].AddDays(-1))]

    Leave a comment:


  • NinjaTrader_JC
    replied
    Hello elitetradernyc,

    This is something also that would have to be calculated if you want to use the PriorDayOHCL() indicator as well.

    Since you are checking for the start of a session you can save the bar that new session starts on so that you can reference it later inside of the PirorDayOHLC().PriorClose[x] so since you know what bar the session started on you can use the "CurrentBar" minus the variable that has the variable that is storing what bar the session you want to access it from.

    Let me know if you have any questions.

    Leave a comment:


  • elitetradernyc
    replied
    Thanks, one other question, I want to get the close of two sessions ago, like PriorDayOHLC().PriorClose[x] but how do you get it to look back two sessions and not just 1?

    Thanks

    Leave a comment:


  • NinjaTrader_JC
    replied
    Hello elitetradernyc,

    You may manually calculate this by using the Bars.FirstBarOfSession and checking for your series. For example:

    Code:
    int counter = 0;
    if(BarsInProgress == 0 && Bars.FirstBarOfSession)
         counter++;


    Happy to be of further assistance.

    Leave a comment:


  • elitetradernyc
    started a topic Get # of Sessions

    Get # of Sessions

    Hi guys, Is there a way to get the # of sessions that have occurred since a backtest started? My primary series is BetterRenko 4, but I want to test how many days have passed during the backtest for my primary series.

Latest Posts

Collapse

Topics Statistics Last Post
Started by kinfxhk, 07-14-2026, 09:39 AM
0 responses
125 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 10:18 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 09:50 AM
0 responses
85 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 07:21 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-11-2026, 02:11 AM
0 responses
84 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X