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 jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        179 views
        0 likes
        Last Post jeronymite  
        Started by ghoul, Today, 06:02 PM
        0 responses
        9 views
        0 likes
        Last Post ghoul
        by ghoul
         
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X