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

Pivot error

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

    #16
    Thanks,

    This is in a custom indicator: It prints the correct value the first time, then the value 0 afterwards.

    I have the logic all working if it is all in a stragey but I need logic with Pivot values in a seperate file. How would you reccomend I do this?



    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Print("OnBarUpdate Indicator");
    printOneZone();
    }

    ///<summary>
    /// Print only the pivot PP Daily
    ///</summary>
    publicvoid printOneZone(){

    double value = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
    Print (
    "printOneZone PP Daily Pivot value is:" + value.ToString());

    }

    Comment


      #17
      Hello Cleo,

      Thank you for your response.

      Please take the calculation logic of the printOneZone() and place this in the OnBarUpdate() method so that it runs in the OnBarUpdate() and advise if this still prints zero.

      Comment


        #18
        Thanks for the responce,

        Yes I get the same thing:


        Code:
        ///<summary>
        /// Called on each bar update event (incoming tick)
        ///</summary>
        protectedoverridevoid OnBarUpdate()
        {
        // Use this method for calculating your indicator values. Assign a value to each
        // plot below by replacing 'Close[0]' with your own formula.
        Print("OnBarUpdate Indicator");
        double value = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
        Print (
        " OnBarUpdate PP Daily Pivot value is:" + value.ToString());
        printOneZone();
        }

        ///<summary>
        /// Print only the pivot PP Daily
        ///</summary>
        publicvoid printOneZone(){

        double value = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
        Print (
        "printOneZone PP Daily Pivot value is:" + value.ToString());

        }


        Output Window:
        OnBarUpdate Indicator
        OnBarUpdate PP Daily Pivot value is:1.0628
        printOneZone PP Daily Pivot value is:1.0628
        OnBarUpdate Indicator
        OnBarUpdate PP Daily Pivot value is:0
        printOneZone PP Daily Pivot value is:0
        OnBarUpdate Indicator
        OnBarUpdate PP Daily Pivot value is:0
        printOneZone PP Daily Pivot value is:0
        OnBarUpdate Indicator
        OnBarUpdate PP Daily Pivot value is:0
        printOneZone PP Daily Pivot value is:0

        Thanks,
        Cleo

        Comment


          #19
          Hello Cleo,

          Thank you for your response.

          Please attach your updated code to your response so I may test this matter on my end.

          I look forward to your response.

          Comment


            #20
            Hello,

            Step 1: Create a new chart (6S 06-13) With 5 Min interval
            Step 2: Open and clear Output window
            Step 3: Right click on chart and click on "Indicators"
            Step 4: Add the PivotIndicatorTester indicator
            Step 5: Verify output

            Thanks for looking into this. I can get this to work fine in a strategy however I need this logic to be in a sperate file. The strategy has 2000 lines of code written by people I work with, and I do not want to touch it.

            Thanks,
            Cleo
            Attached Files

            Comment


              #21
              Hello Cleo,

              Thank you for your patience.

              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:

              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());
              }
              - Taken from Pivots in the NinjaTrader Help Guide under Indicator Methods: http://www.ninjatrader.com/support/h...nt7/pivots.htm

              Please let me know if you have any questions.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              157 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Today, 09:29 PM
              0 responses
              6 views
              0 likes
              Last Post Belfortbucks  
              Started by zstheorist, Today, 07:52 PM
              0 responses
              7 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              151 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Working...
              X