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

Bars.GetDayBar on Multi Time Frame

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

    Bars.GetDayBar on Multi Time Frame

    E.g. I have added several intraday data series to my script using Add("ticker", PeriodType.Minute, 1). I want a reliable and efficient method to find yesterdays close for all of them, e.g. like Bars.GetDayBar.Close or something. Any ideas?

    For consistency, I would like to avoid adding a Daily series for each of my instruments: The close will be different on the daily to the intraday data.

    I'm getting inconsistent results using things like the following, as the instruments can have different timings etc:

    if (BarsInProgress == 0 && Bars.FirstBarOfSession && FirstTickOfBar)
    {
    timeOfInterest = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day);
    }

    openBar = GetBar(timeOfInterest);
    Closes[x][openBar] //Gives inconsistent result!

    #2
    Hello Antimatter,

    There is PriorDayOHLC() for this.



    You can pass in the BarsArray for the specific series you want for this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      That's great thanks.

      Now I'm struggling to find a realiable way to get the TodaysOpen for each instrument in my list...?! Same problem as before.

      Comment


        #4
        You can use CurrentDayOHL()
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          GetDayBar()

          A strategy works on a five minute chart with this line causing it not to fire:

          && CurrentDayOHL().CurrentOpen[0] < Bars.GetDayBar(2).Low

          Adding this to initialize helped...

          Add("ES 06-12", PeriodType.Day, 20);

          But the strategy still does not plot the execution on the graph. Any ideas why that might be?

          Also I could not find a monthly and weekly OHLC that plots on the current session. Any ideas about that?

          Regards and thx
          Last edited by elliot5; 04-23-2012, 02:06 AM. Reason: extra information

          Comment


            #6
            Hi everington_f,

            For weekly and monthly series these must be added to the script to initialize. There are not built in methods that calculate these from intraday data like the CurrentDay, PriorDay, GetDayBar do for daily bars.

            To find out why your script is not entering as you expect, debug it by checking values used in entry conditions. Help for debugging your NinjaScript is available here:
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              OK Thanks. I was kind of hoping that someone out there had an indicator the the previous month and week OHLC. Thanks for your input.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jclose, Today, 09:37 PM
              0 responses
              5 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,413 views
              0 likes
              Last Post Traderontheroad  
              Started by firefoxforum12, Today, 08:53 PM
              0 responses
              11 views
              0 likes
              Last Post firefoxforum12  
              Started by stafe, Today, 08:34 PM
              0 responses
              11 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by sastrades, 01-31-2024, 10:19 PM
              11 responses
              169 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X