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

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
                  Josh P.NinjaTrader 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 Mizzouman1, Today, 07:35 AM
                      3 responses
                      17 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by RubenCazorla, Today, 09:07 AM
                      2 responses
                      13 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by i019945nj, 12-14-2023, 06:41 AM
                      7 responses
                      82 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by timmbbo, 07-05-2023, 10:21 PM
                      4 responses
                      158 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by tkaboris, Today, 08:01 AM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Working...
                      X