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

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

        Represents an instant in time, typically expressed as a date and time of day.


        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 Stanfillirenfro, Today, 07:23 AM
                8 responses
                23 views
                0 likes
                Last Post Stanfillirenfro  
                Started by DayTradingDEMON, Today, 09:28 AM
                2 responses
                15 views
                0 likes
                Last Post DayTradingDEMON  
                Started by navyguy06, Today, 09:28 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                8 responses
                32 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by helpwanted, Today, 03:06 AM
                2 responses
                22 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X