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:
    int barsperday = 1440 / Bars.Period.Value;
    closeratio = PriorDayOHLC().PriorClose[(i-1)*barsperday]/PriorDayOHLC().PriorClose[i*barsperday];
    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 jcbinks, Today, 03:32 PM
        2 responses
        15 views
        0 likes
        Last Post jcbinks
        by jcbinks
         
        Started by Stefan Mayer, Today, 03:09 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by M_ichel, Today, 03:18 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by ralett, Today, 02:43 PM
        2 responses
        16 views
        0 likes
        Last Post ralett
        by ralett
         
        Started by Nightmaregpu, Today, 02:18 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X