• 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.


No announcement yet.

Partner 728x90


Pivot Point Mod for Open & Close Times

  • 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.

    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


      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.


        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


          Thanks, I'll give it a shot !


            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?



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


                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.



                  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.

                  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
                  Josh P.NinjaTrader Customer Service


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


                      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.


                      Latest Posts


                      Topics Statistics Last Post
                      Started by abdullah, 11-15-2017, 08:44 PM
                      10 responses
                      Last Post Lancer
                      by Lancer
                      Started by brunoviveiros, Today, 04:31 AM
                      2 responses
                      Last Post brunoviveiros  
                      Started by foxy_rav, Today, 06:31 AM
                      1 response
                      Last Post NinjaTrader_Jim  
                      Started by neilzep, Today, 06:42 AM
                      1 response
                      Last Post NinjaTrader_Jesse  
                      Started by teafortwo, Today, 04:26 AM
                      3 responses
                      Last Post NinjaTrader_PaulH