• 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

Calling Pivot Point returns 0 temporarily

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

    Calling Pivot Point returns 0 temporarily

    Hi,

    I am calling the pivot point indicator from another indicator I have.

    This is how I am calling it in my indicator

    double temp =Pivots1(PivotRange.Daily,HLCCalculationMode.Daily Bars,0,0,0,0).GetVal();

    Then I am immediately printing to the output window to check the val

    Print ("Pivot is - "+temp);

    This is the function I have added to the Piivot indicator to return the val

    public double GetVal()
    {
    Update();
    return (pp);
    }

    The strange thing is that on the first couple of returns, the value is "0" then after a tick it kicks in and returns correctly.

    Can anyone shed some light on why it is returning "0" first even though i am updating?

    Thanks for any help.

    #2
    Hi Marty087,

    Thank you for your post.

    You will need to set the bars required to 0 for the Indicator -
    BarsRequired = 0; in the Initialize() method.

    http://www.ninjatrader.com/support/h...rsrequired.htm
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks again Cal.... Doesnt seem to work though. Still only gives me a 0 until a tick goes by. I noticed that there is quite a delay when adding the Pivot indicator(NT supplied) onto the chart, could this have something to do with it?

      I just did a quick work around by calculating the pivots within my indi like this

      #region GetPivots

      void GetPivots()

      {
      //Add(PeriodType.Day, 1); // put in initialize
      double currentClose = Closes[1][1];
      double currentHigh = Highs[1][1];
      double currentLow = Lows[1][1];
      pp = (currentHigh + currentLow + currentClose) / 3;
      s1 = 2 * pp - currentHigh;
      r1 = 2 * pp - currentLow;
      s2 = pp - (currentHigh - currentLow);
      r2 = pp + (currentHigh - currentLow);
      s3 = pp - 2 * (currentHigh - currentLow);
      r3 = pp + 2 * (currentHigh - currentLow);


      }
      #endregion

      But the problem then is that the indi runs twice on every tick (one for each instance/time frame) and this will chew up valuable resources for me.....

      Any suggestions.

      Cheers.

      Comment


        #4
        Marty087,

        If you are using different time frames, you can use BarsInProgress to filter out the ticks that are calling OnBarUpdate()
        http://www.ninjatrader.com/support/h...inprogress.htm

        Additionally, you can use FirstTickOfBar to only have any thing after that calculate on the first tick of a new bar.
        http://www.ninjatrader.com/support/h...ttickofbar.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Due to internal synchronization issues, the Pivots indicator cannot be called in DailyBars mode. This is a know issue with NinjaTrader 7 and will hopefully be addressed with NinjaTrader 8.

          The only way to call the pivots from another indicator or a strategy is to use

          HLCCalculationMode.CalcFromIntradayData

          Attached is a sample indicator to access the pivots. You will see the problem confirmed, when the pivots are accessed in HLCCalculationMode.DailyBars.
          Attached Files

          Comment


            #6
            Thanks Harry, this explains the issues i've been having.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by safbrathpro, Today, 05:51 AM
            0 responses
            4 views
            0 likes
            Last Post safbrathpro  
            Started by abfefmu, Today, 05:33 AM
            0 responses
            4 views
            0 likes
            Last Post abfefmu
            by abfefmu
             
            Started by bbdjad, Today, 04:36 AM
            0 responses
            4 views
            0 likes
            Last Post bbdjad
            by bbdjad
             
            Started by mittie3, Today, 03:33 AM
            0 responses
            7 views
            0 likes
            Last Post mittie3
            by mittie3
             
            Started by Againmain1, Today, 03:04 AM
            0 responses
            8 views
            0 likes
            Last Post Againmain1  
            Working...
            X