• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pivot Point Mod for Open & Close Times

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

    Pivot Point Mod for Open & Close Times

    Hi. I'm trying to modify a copy of the ninjascript for Pivot points so that daily pivots can be calculated from the start of the Globex session the prior day - meaning, for example, that I would like to calculate today's pivot points (8/31) from the globex open at 4:30 pm on 8/29 to the close of the cash session at 4:15 on 8/30, and using the high from within that date and time range ..... (open + high + close)/3.
    >
    Can someone help me figure out the coding for this? I have a programming background and have already modified some of the ninjascript indicators before, but so far I am stuck on this one.
    >
    I'm thinking that the section of the code that i need to modify is the part of OnBarUpdate() that defines currentClose, currentHigh and currentLow.
    >
    Thanks!

    #2
    You could internally set up your session start/end times via DateTime variables, then check in OnBarUpdate() when a new session time starts, and on the first bar >= to the session start time, store the open for example.

    NT6.5 due out in beta in late September will support sessions that span two days allowing you to set the true Globex session times and thus use our standard pivot indicators.
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray, thank you. Sorry for newbie question, but how would I go about doing what you suggest?

      You could internally set up your session start/end times via DateTime variables, then check in OnBarUpdate() when a new session time starts, and on the first bar >= to the session start time, store the open for example.



      Comment


        #4
        Here is a conceptual idea:

        private DateTime myStartTime = new DateTime(2007, 08, 31, 16, 30, 0);

        if (Time[0].TimeOfDay.TotalSeconds >= myStartTime.TimeOfDay.TotalSeconds)
        // Here is our first bar after a user defined start time
        RayNinjaTrader Customer Service

        Comment


          #5
          Thanks, I'll give it a shot !

          Comment


            #6
            Hi ...

            I'm floundering with this ... I was able to add the variable definition for myStartTime and still compile ok, but can't quite figure out wher to put the if statement ....

            Any chance I can get some handholding on this?

            Also, any reference that you can point me to that will help me get up to speed on NinjaScript in general?

            Thanks,
            Charlie

            Comment


              #7
              I should also say that I'm starting by modifying a copy of the "Pivots" indicator that comes with NibjaTrader ... thanks.

              Comment


                #8
                I found the NinjaScript section in help and am going through it, so no need to point me to a source.

                ... but please, could still use some help with the actual indicator development.

                Thanks.

                Comment


                  #9
                  Hi cutter,

                  What you want to do is work in the OnBarUpdate() section of your code. Whatever is in the OnBarUpdate() will be run through every time your bar is updated, whether that is at the end of the bar (when CalculateOnBarClose = true) or at every incoming tick (when CalculateOnBarClose = false).

                  For the pivots indicator you are trying to make you can do so by checking the time of your bars. If the time is the time you want then you would store away your Open High Close values for use on the pivots.

                  Here is a code snippet demonstrating how you could theoretically proceed with your idea.

                  Code:
                  if (ToDay(Time[0]) == (ToDay(DateTime.Now) - 1))
                  {
                       globexopen = Open[0];
                       globexhigh = High[0];
                       globexclose = Close[0];
                  }
                  After you have saved the proper OHC values you would pass those into the Pivot calculations instead of the default ones used. Now this exact code wouldn't be enough to handle your situation because you need to handle weekends where minus 1 wouldn't be enough, but you get the idea.

                  FYI: The ToDay() function returns an integer representing the date of the DateTime object. Time[0] is the DateTime object timestamped for the particular bar your indicator is calculating on at the moment and DateTime.Now is the DateTime object representing the exact time right now (i.e. your computer's current system time).

                  Hope that helps. Also you may find using these as reference useful http://www.ninjatrader-support.com/v...ead.php?t=2777
                  JoshNinjaTrader Customer Service

                  Comment


                    #10
                    Josh, thank you so much, this is a big help to me. Will give it a try and post results.

                    Comment


                      #11
                      Half pivots

                      I think its easy to implement but i am simply not a programmer, so if anyone could post here a pivot point modification that shows the price in the middle of two pivot lines for example (PP+S1 / 2)+S1 I would be more than happy.

                      Reading in the book MASTERING THE TRADE, this is one of the key setups to reduce position size.

                      Maybe also in NT 6.5 we could find this important update to the pivot indicator.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by algotrading, 07-18-2018, 10:41 PM
                      2 responses
                      920 views
                      1 like
                      Last Post gbux11
                      by gbux11
                       
                      Started by supermht, Yesterday, 10:13 PM
                      0 responses
                      2 views
                      0 likes
                      Last Post supermht  
                      Started by supermht, Yesterday, 07:59 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post supermht  
                      Started by mohdhm, Yesterday, 05:13 PM
                      1 response
                      18 views
                      0 likes
                      Last Post nkhoi
                      by nkhoi
                       
                      Started by 3lliot, Yesterday, 05:55 PM
                      0 responses
                      4 views
                      0 likes
                      Last Post 3lliot
                      by 3lliot
                       
                      Working...
                      X