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 DJ888, 04-16-2024, 06:09 PM
              4 responses
              12 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              9 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              6 views
              0 likes
              Last Post nandhumca  
              Started by The_Sec, Today, 03:37 PM
              0 responses
              3 views
              0 likes
              Last Post The_Sec
              by The_Sec
               
              Started by GwFutures1988, Today, 02:48 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X