Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily, Weekly, Monthly Open time without MTF

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

    Daily, Weekly, Monthly Open time without MTF

    Hi guys!

    How can I get these sessions open time?

    thx in advance
    w.

    #2
    Hello,

    You can do this by using the GetNextBeginEnd

    Details for using this are found here:



    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Hi Lance!

      Thx for your quick reply...

      Could u give me a little hint please?

      Before I tried this...

      Add(PeriodType.Week, 1);
      Add(PeriodType.Day, 1);
      Add(PeriodType.Month, 1);

      But I don't know find solution with BarsArray[1] Time[0] //Weekly open time.
      Or if it's better to get barsago...that would be great too...

      thanks again.
      w

      Comment


        #4
        Getting the opening time of a weekly bar gets a bit more complicated. The time stamp of a bar reported will always be the closing time. Depending on your data provider and instrument being used you might be able to get the closing time stamp and subtract ~7 days



        Time[0] would get you the correct time when run in real time with CalculateOnBarClose = false
        But in a backtest it would only return at the close of the bar

        Another route would be to take a smaller series and pull the time value from that at the start of the week.

        Let me know if I can further assist.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Ok, back to the topic.

          So how can i get daily, yesterday, week and monthly open time?

          Could u give me a sample please. I can't figure out.


          thanks in advance
          w

          Comment


            #6
            This is what i tried:


            CalculateOnBarClose = false;


            Add(PeriodType.Week, 1);
            Add(PeriodType.Day, 1);
            Add(PeriodType.Month, 1);


            if (Bars.GetDayBar(2) != null && BarsInProgress == 2)
            {
            yesterdayOpen = Time[2];
            dailyOpen = Time[1];
            }


            if (Bars.GetDayBar(2) != null && BarsInProgress == 0)
            {
            DrawLine("d_open", false, dailyOpen, DOpenprice, Time[0].AddHours(3), DOpenprice, Color.Magenta, DashStyle.Solid, 1); // daily open line

            DrawLine("y_open", false, yesterdayOpen, YOpenprice, Time[0].AddHours(3), YOpenprice, Color.FromArgb(255,255,195,255), DashStyle.Solid, 1); // yesterday open line
            }




            And the error message is:

            Error on calling 'OnBarUpdate' method for indicator 'Keri' on bar 192: Keri.DrawLine: startTime must be greater/equal the minimum Date but was 0001.01.01. 0:00:00

            Comment


              #7
              This indicator package contains 6 indicators. The anaCurrentDayOHLV42, anaCurrentWeekOHLV42 and anaCurrentMonthOHLV42 indicators display the daily, weekly and monthly open. Yesterday's open is only displayedm because it is August 2nd now.



              The indicators use the session template to detect the open bar. You need to use anappropriate session template - as selected under instrument settings - to get the correct open. With subdivided session templates it is also possible to display the regular open instead of the full session open.

              Comment


                #8
                Ok thanks.
                I'll check it out...

                w.

                Comment

                Latest Posts

                Collapse

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