Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrader 8 Beta 2 OnCalculateMinMax() And CalculateMinMax()

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

    NinjaTrader 8 Beta 2 OnCalculateMinMax() And CalculateMinMax()

    .
    I have tried all examples of these Methods from the "Help" documentation for NT8 for OnCalculateMinMax() And CalculateMinMax() and none of these Method examples will compile. Is there a problem here?

    ----------------------------------------------------------------------------------------------------------------

    public override void OnCalculateMinMax()
    {
    //It is important to set MinValue and MaxValue to the min/max Y values
    //in order for your object to support auto scale
    MinValue=Anchor.YDataValue;
    MaxValue=Anchor.YDataValue;
    }


    -------------------------------------------------------------------------------------------------------

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {

    IsAutoScale = true; // set this to true to call CalculateMinMix() to ensure drawing tool is fully rendered in chart scale
    }
    }

    public override void CalculateMinMax()
    {
    // It is important to set MinValue and MaxValue to the min/max Y values your drawing tool uses if you want it to support auto scale
    foreach (ChartAnchor anchor in Anchors)
    {
    MinValue = Math.Min(anchor.YDataValue, MinValue);
    MaxValue = Math.Max(anchor.YDataValue, MaxValue);
    }
    }

    ---------------------------------------------------------------------------------------------------------


    public override void OnCalculateMinMax()
    {
    //It is important to set MinValue and MaxValue to the min/max Y values
    //in order for your object to support auto scale
    MinValue=Anchor.YDataValue;
    MaxValue=Anchor.YDataValue;
    }
    .
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    The OnCalculateMinMax() documentation referrers to "Chart Anchors" which are part of DrawingTools, I'll have that updated to work within the context of the indicators.

    Here is a basic example of what you'd be doing in an indicator

    Code:
    public override void OnCalculateMinMax()
    {		
    	//Set the charts min/max values to 50 Ticks above/below MyPlot
    	MinValue = MIN(MyPlot, 50)[0] - 50 * TickSize;
    	MaxValue = MAX(MyPlot, 50)[0] + 50 * TickSize;
    }
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew,

      Thank you for making the changes described to the documentation.

      Please take this code sample you posted here and place it inside an indicator and compile.

      You will then see why I posted a possible bug report.

      RJay

      Originally posted by NinjaTrader_Matthew View Post
      The OnCalculateMinMax() documentation referrers to "Chart Anchors" which are part of DrawingTools, I'll have that updated to work within the context of the indicators.

      Here is a basic example of what you'd be doing in an indicator

      Code:
      public override void OnCalculateMinMax()
      {        
          //Set the charts min/max values to 50 Ticks above/below MyPlot
          MinValue = MIN(MyPlot, 50)[0] - 50 * TickSize;
          MaxValue = MAX(MyPlot, 50)[0] + 50 * TickSize;
      }
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        That works for me as long as I have a MyPlot series... what error are you getting?

        The min/max needs to be anchored to some price point, I suppose you can replace that with Close for demonstration purposes.

        Code:
        public override void OnCalculateMinMax()
        {        
            //Set the charts min/max values to 50 Ticks above/below MyPlot
            MinValue = MIN(Close, 50)[0] - 50 * TickSize;
            MaxValue = MAX(Close, 50)[0] + 50 * TickSize;
        }
        MatthewNinjaTrader Product Management

        Comment


          #5
          Errors in compiler as follows:
          -----------------------------------------------------------------

          Statement expected.

          Class, delegate, interface, or struct expected.

          External alias declarations, using clauses, assembly module attributes, or namespace/type declarations expected.

          ------------------------------------------------------------------

          Can you please post your indicator's listing of #region Using declarations.

          Thanks.

          Originally posted by NinjaTrader_Matthew View Post
          That works for me as long as I have a MyPlot series... what error are you getting?

          The min/max needs to be anchored to some price point, I suppose you can replace that with Close for demonstration purposes.

          Code:
          public override void OnCalculateMinMax()
          {        
              //Set the charts min/max values to 50 Ticks above/below MyPlot
              MinValue = MIN(Close, 50)[0] - 50 * TickSize;
              MaxValue = MAX(Close, 50)[0] + 50 * TickSize;
          }
          RJay
          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

          Comment


            #6
            Attached is a complete indicator which overrides OnCalculateMinMax
            Attached Files
            MatthewNinjaTrader Product Management

            Comment


              #7
              OK, that sample works. Thanks. I can manage from here.
              RJay
              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

              Comment


                #8
                Hello meinl, and thank you for your queries.

                We have updated the Help Guide example for OnCalculateMinMax. Please let us know if there are any other ways we can help.

                Last edited by NinjaTrader_JessicaP; 06-06-2016, 02:06 PM.
                Jessica P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                1 view
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                34 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                6 views
                0 likes
                Last Post cls71
                by cls71
                 
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                216 views
                1 like
                Last Post PaulMohn  
                Working...
                X