Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pivot Indicator

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

    Pivot Indicator

    Am trying to create a very simple pivot strategy.

    Can't seem to get all of the day bars I need loaded so as to begin.

    Any advice?

    Ty,

    Andrew

    #2
    Hi Andrew,
    Sorry, not sure. Is there an error message you're getting? What are you doing to "get all of the day bars"?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      the strat compiles fine; it will not work in a backtesting situation, althought I am not sure why;

      **NT** Failed to call method 'Initialize' for strategy 'BasicPivot/75a489a2cf07402db56bc4445c3e6458': Object reference not set to an instance of an object.

      Comment


        #4
        OK -- what code are you using when you get this error message?
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Add(Pivots(NinjaTrader.Data.PivotRange.Daily, NinjaTrader.Data.HLCCalculationMode.CalcFromIntrad ayData, 0, 0, 0, 20));

          //Returns PP value
          double pivotPoint = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];

          //Returns R1 value
          double resistance1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).R1[0];


          //Returns S1 value
          double support1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).S1[0];

          Comment


            #6
            Thanks. Initialize() is not used for accessing indicator values, those belong in OnBarUpdate() instead.

            You can see here for what Initialize() is typically used for:
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              much better and we are working now but when i backtest my strat all pivot values still print as zero...any quick fix or am i in deep at this point?

              Comment


                #8
                The main thing to check here is that your calculation mode is set properly for the interval you're viewing. This may seem counter intuitive, but it's:

                intraday charts - > use mode daily.
                daily chart - > use mode weekly.
                weekly charts - > use mode monthly.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  I get what you are saying and i think that we are close here, but i think what i need is a bit more specific direction:

                  ---my pivots need to use data from prior day so that they apply today

                  ---my closes need to be "minute, or "tick" based


                  I am not a coder but know just enough to be dangerous....

                  how do i set this so that i can see today's pivot points...if i can do this, i can certainly add this result to my otherwise flushed out strategy.

                  Keep in mind that for now, this is a backtesting exercise.

                  Thanks in advance,

                  Andrew

                  Comment


                    #10
                    just wanted to get a bit of clarity on ryanm's last post.

                    I am sure that any of the NT forum moderators should be able to clarify the response.

                    thanks in advance.

                    Andrew
                    Last edited by alabell; 07-27-2012, 07:09 AM.

                    Comment


                      #11
                      Originally posted by NinjaTrader_RyanM View Post
                      The main thing to check here is that your calculation mode is set properly for the interval you're viewing. This may seem counter intuitive, but it's:

                      intraday charts - > use mode daily.
                      daily chart - > use mode weekly.
                      weekly charts - > use mode monthly.
                      Could really use help so i can do soem work this weekend.

                      Assuming I am using intraday charts, where do i set the day bars, in the code or in the backtest GUI? right now I have no day bars or minute bars added in the code, because i dont't see where i would reference them in the pivot point function.

                      Thanks kindly.

                      Andrew

                      Comment


                        #12
                        Hello Andrew,
                        Thanks for your note and I am replying for Ryan.

                        You have to set what type of data/mode etc you will be using from the code itself.

                        Suppose you are backtesting on a 5 minute bar then the pivot code will be like

                        Code:
                        double pivotPoint = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
                        if you want the pivots to be calculated from intraday bars then you will have to use the code as

                        Code:
                        double pivotPoint = Pivots(PivotRange.Daily, [B]HLCCalculationMode.CalcFromIntradayData[/B], 0, 0, 0, 20).PP[0];

                        Please let me know if I can assist you any further.
                        JoydeepNinjaTrader Customer Service

                        Comment


                          #13
                          that seems very helpful, so if i wanted to backtest the price of a stock every one minute bar against the pivot points for that day, I would use first example correct?

                          Comment


                            #14
                            Hello Andrew,
                            Yes, you will have to use the first code.

                            Please let me know if I can assist you any further.
                            JoydeepNinjaTrader Customer Service

                            Comment


                              #15
                              So I have one more question before we hit the the weekend and i am left to fend for myself:


                              why would this code, when backtested for calendar year 2012 (from jan through july) yield only trades from the last 3-4 trading days?

                              Thanks in advance,

                              Andrew

                              code below
                              _____________________________

                              protected override void OnBarUpdate()

                              {



                              //Returns PP value
                              pivotPoint = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0];

                              //Returns R1 value
                              resistance1 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).R1[0];

                              //Returns R2 value
                              resistance2 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).R2[0];

                              //Returns R3 value
                              resistance3 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).R3[0];

                              //Returns S1 value
                              support1 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).S1[0];

                              //Returns S2 value
                              support2 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).S2[0];

                              //Returns S3 value
                              support3 = Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).S3[0];



                              /*
                              // Condition set 1
                              if ((Closes[0][1] <= Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0]*1.0002)
                              && (Closes[0][1] >= Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0]*1.0000))
                              {


                              EnterLong(100);//Limit(100, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0]*1.0002, "pivotBuyLong");
                              Print("The current Pivots' pivot value is " + pivotPoint.ToString());
                              Print("The current Long Entry value is " + ((pivotPoint)*1.0002).ToString());
                              }
                              // Condition set 2
                              else if ((Closes[0][1] >= Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0]*0.9998)
                              && (Closes[0][1] <= Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0]*1.0000))
                              {


                              EnterShort(100);//Limit(100, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0]*0.0098, "pivotSellShort");
                              Print("The current Pivots' pivot value is " + pivotPoint.ToString());
                              Print("The current Short Entry value is " + ((pivotPoint)*0.9998).ToString());

                              */

                              if ((Closes[0][1] <= pivotPoint*1.0002)
                              && (Closes[0][1] > pivotPoint))

                              {


                              EnterLong(100);//Limit(100, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0]*1.0002, "pivotBuyLong");
                              Print("The current Pivots' pivot value is " + pivotPoint.ToString());
                              Print("The current Long Entry value is " + ((pivotPoint)*1.0002).ToString());

                              }

                              /*// Condition set 2
                              else if ((Closes[0][1] >= pivotPoint*0.9998)
                              && (Closes[0][1] < pivotPoint))
                              {


                              EnterShort(100);//Limit(100, Pivots(PivotRange.Daily, HLCCalculationMode.CalcFromIntradayData, 0, 0, 0, 20).PP[0]*0.0098, "pivotSellShort");
                              Print("The current Pivots' pivot value is " + pivotPoint.ToString());
                              Print("The current Short Entry value is " + ((pivotPoint)*0.9998).ToString());





                              }*/
                              }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              77 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              27 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              62 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X