Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to get priorclose from days previous to the previous

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

    Best way to get priorclose from days previous to the previous

    I am having trouble figuring the best way to find the priorclose 2, 3+ days ago...

    The closest I can get (no cigar, not accurate) is this:

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] barsperday = [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1440[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] / Bars.Period.Value;
    [/SIZE][/FONT][FONT=Courier New][SIZE=2]closeratio = PriorDayOHLC().PriorClose[(i-[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])*barsperday]/PriorDayOHLC().PriorClose[i*barsperday];[/SIZE][/FONT]
    But obviously no contracts actually trade the entire 24 hrs (and thus have 1440 minutes of bars). So any idea how to get priordayohlc in *session* terms instead of *bar* terms?

    Same goes for not running an indicator unless X days of data are present ? Instead of
    Code:
     
    if (CurrentBar < barsperday * period)
        return;
    What is recommended?

    #2
    ok figured this out by myself...

    This does the job. BTW, is bars.getsessionbar(0) the close of the last session or the current session?

    closeratio = Bars.GetSessionBar(i).Close/Bars.GetSessionBar(i+
    1).Close;

    Now I need to figure out how to have the indicator return if I don't have enough data (ie it needs i days of data minimum).

    Comment


      #3
      OK Second problem solved.

      if (Bars.BarsSinceSession == 1)
      sessioncount++;
      if (sessioncount < period+2)
      return;

      Comment


        #4
        Glad you figured it out.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X