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

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 memonic, Yesterday, 01:23 PM
        2 responses
        12 views
        0 likes
        Last Post memonic
        by memonic
         
        Started by merc410, Today, 03:41 AM
        2 responses
        13 views
        0 likes
        Last Post merc410
        by merc410
         
        Started by sugalt, 04-30-2024, 04:02 AM
        2 responses
        13 views
        0 likes
        Last Post sugalt
        by sugalt
         
        Started by Ndakotan1313, 03-14-2024, 05:02 PM
        2 responses
        64 views
        0 likes
        Last Post blaise_code  
        Started by claxxical, 05-30-2017, 12:30 PM
        37 responses
        4,464 views
        0 likes
        Last Post Padan
        by Padan
         
        Working...
        X