Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pivots R1, R2, ... values

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

    Pivots R1, R2, ... values

    Hi

    How can I get the Pivots R1, R2, ... values?

    I always get 0.

    protected override void OnBarUpdate()
    {
    Pivots pivots = Pivots(Input, PivotRange.Daily, HLCCalculationMode.DailyBars, 0,0,0,20);
    Print(pivots.R1[0]);
    }

    Regards

    #2
    You cannot call the pivots with setting HLCCalculationMode.DailyBars. The call is not correctly synchronized by NinjaTrader. You can only call pivots when set to HLCCalculationMode.CalcFromIntradayData.

    Otherwise if you need to calculate pivots from daily bars, you can copy the entire indicator to a strategy or indicator instead of calling it.
    Last edited by Harry; 10-05-2014, 09:13 AM.

    Comment


      #3
      Hello davidgamo,

      Thank you for your post.

      When using HLCCalculationMode.DailyBars it can be expected that a value of 0 is returned when the daily bars have not been loaded yet. Due to the asynchronous nature of this indicator calling daily bars you should only access the pivot values when the indicator has loaded all required Bars objects. To ensure you are accessing accurate values you can use .ContainsValue() as a check.

      For example:
      Code:
      // Checks that this is a valid pivot point value
      if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP.ContainsValue(0))
      {
          // Prints the current pivot point value
          double value = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
          Print("The current Pivots' pivot value is " + value.ToString());
      }

      Comment


        #4
        Hi Patrick,

        This does not work with the pivots indicator. You cannot call its values from another indicator or strategy, even when the daily bars are loaded. This is a limitation of the asynchronous call. If you find a solution to overcome the problem. please let me know.

        Attached is an indicator that accesses the pivots and which shows the problem. If you set "DailyBars" to "true" (default setting) nothing will be displayed. If you set "DailyBars" to false, it will display the pivots, as the indicator can only retrieve the values from the NinjaTrader default pivots indicator, when it does not use daily data.


        Originally posted by NinjaTrader_PatrickH View Post
        Hello davidgamo,

        Thank you for your post.

        When using HLCCalculationMode.DailyBars it can be expected that a value of 0 is returned when the daily bars have not been loaded yet. Due to the asynchronous nature of this indicator calling daily bars you should only access the pivot values when the indicator has loaded all required Bars objects. To ensure you are accessing accurate values you can use .ContainsValue() as a check.

        For example:
        Code:
        // Checks that this is a valid pivot point value
        if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP.ContainsValue(0))
        {
            // Prints the current pivot point value
            double value = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
            Print("The current Pivots' pivot value is " + value.ToString());
        }
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        559 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        546 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X