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

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 rajendrasubedi2023, Today, 09:50 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by lorem, Today, 09:18 AM
            2 responses
            11 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by geddyisodin, Today, 05:20 AM
            4 responses
            29 views
            0 likes
            Last Post geddyisodin  
            Started by geotrades1, Today, 10:02 AM
            2 responses
            10 views
            0 likes
            Last Post geotrades1  
            Started by ender_wiggum, Today, 09:50 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X