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 alifarahani, Today, 09:40 AM
        4 responses
        20 views
        0 likes
        Last Post alifarahani  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PhillT, Today, 02:16 PM
        2 responses
        7 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by Kaledus, Today, 01:29 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Yesterday, 09:08 AM
        14 responses
        47 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X