• 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

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());
      }
      Patrick H.NinjaTrader Customer Service

      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 Atilla, Today, 04:05 PM
        0 responses
        16 views
        0 likes
        Last Post Atilla
        by Atilla
         
        Started by Displacer, Today, 02:57 PM
        2 responses
        13 views
        0 likes
        Last Post Displacer  
        Started by SAILIKITY, 05-22-2019, 05:41 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by rmillar, 01-09-2019, 06:02 PM
        6 responses
        74 views
        1 like
        Last Post eDanny
        by eDanny
         
        Started by mlarocco, Today, 11:39 AM
        4 responses
        23 views
        0 likes
        Last Post mlarocco  
        Working...
        X