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

when is OnCalculateMinMax() is called?

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

    when is OnCalculateMinMax() is called?

    Hello, I don’t understand when OnCalculateMinMax() is called?

    If I have an override OnCalculateMinMax() in my indicator, then the method is called as I’m expecting.

    However, if I have OnCalculateMinMax in a subclass, like “public class MyPlot : DrawingTool” (very much the same as the Line.cs in the folder DrawingTools), the method is never called.

    Please, can anyone tell me why OnCalculateMinMax never called?

    Regards, AndBro

    #2
    Hello,

    Thank you for the question.

    I wanted to check, does your tool currently have AutoScale set to true? If not, this method should not be called. Otherwise when it is set to true, you should see this called when the chart requests to check for the Min/Max values. This can occur for incoming data, mouse dragging the chart and a lot of other actions.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse.
      Changing to AutoScale made a call as expected. Now I can continue working, and find out all other bugs I have

      Thank you, AndBro

      Comment


        #4
        Hello Jesse, I was too quick in my conclusion that setting AutoScale to true should solve the problem. The trace of my override OnCalculateMinMax() was printed due to a ”forced” call to the method, and not by setting AutoScale. Sorry.

        I’m back to #1 again.

        No matter how I deal with OnCalculateMinMax(), I can only have it to work when the override method is in the indicator, not in the subclass!

        Everything else works fine. But, I have to manually set the scale manually to see the plot ...

        Regards, Andbro
        Attached Files

        Comment


          #5
          Hello,

          Thank you for the reply.

          Unfortunately, I cannot tell from this sample what may be happening as this is not a complete export that I can compile to test.

          Have you tried to create a structure like the built in drawing tools such as the Line tool and how the other Line objects extend from Line which inherits from DrawingTool? This would be the suggested approach at subclassing a DrawingTool and to ensure the sub classes also have their overrides called.

          I look forward to being fo further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Hello Jesse

            Ok, I understand. I will try to make a mini-example which you can compile. Send you that later …

            Meanwhile, I have already made my subclass (overrides OnCalculateMinMax()) as a subclass of DrawingTool (same as Line.cs in folder DrawingTools)

            My main assumption is: If a class is a subclass of DrawingTool, then any object of this class will have a call to its override OnCalculateMinMax (if that event occurs).

            Main question:
            Is my assumption correct, or are there more conditions to meet?

            Regards, AndBro

            Comment


              #7
              Hello Jesse

              I have attached a small example, and indicator and a helpclass.

              The override OnCalculateMinMax() is called at the indicator, but the override OnCalculateMinMax() in the helpclass is never called? Very confusing!

              Regards, AndBro
              Attached Files

              Comment


                #8
                Hello AndBro,

                It looks like you are trying to override a system method from another class, which won’t be possible.

                What is your objective in trying to override OnCalculcuateMinMax from another class?

                I look forward to your reply.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Alan,

                  Shortely, I have a help class doing additional plotting. To have this help class working, I need to override OnCalculcuateMinMax in my indicator, and for every other indicator using this help class as well.
                  To avoid an override OnCalculcuateMinMax in “every” indicator, my plan is to have the override OnCalculcuateMinMax at the help class, exactly in the same way as in Line.cs
                  As far as I know, my implementation of my help class is the same as Line.cs (a subclass of DrawingTool). If Line.cs is working, my help class should also work, but it do not. There must be something I am not aware of (or other unknown things going on), which makes my help class not having a call to its OnCalculcuateMinMax.

                  How can the override OnCalculcuateMinMax in Line.cs be called, and not at my help class?

                  Regards Andbro

                  Comment


                    #10
                    Hello AndBro,

                    It is not possible to override OnCalculateMinMax from outside the class calling it due to it being a system method. You will have to add the override block in each indicator.

                    Please let us know if you need further assistance.
                    Alan P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Alan,

                      Thank you for your recommendation of how to use OnCalculateMinMax .

                      We can drop this thread at this point. I will go for your recommendation (but I guess that I in the future will dig more into this mystery …)

                      Regards Andbro

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by GwFutures1988, Today, 02:48 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by ScottWalsh, 04-16-2024, 04:29 PM
                      6 responses
                      30 views
                      0 likes
                      Last Post ScottWalsh  
                      Started by frankthearm, Today, 09:08 AM
                      10 responses
                      36 views
                      0 likes
                      Last Post frankthearm  
                      Started by mmenigma, Today, 02:22 PM
                      1 response
                      4 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by NRITV, Today, 01:15 PM
                      2 responses
                      10 views
                      0 likes
                      Last Post NRITV
                      by NRITV
                       
                      Working...
                      X