Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ScottWalsh, Today, 06:52 PM
        4 responses
        32 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        4 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        19 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X