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

OnCalculateMinMax not running

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

    OnCalculateMinMax not running

    Hello,

    I have a set of circumstances (not defined yet), where sometimes, OnCalculateMinMax appears to not get called.

    An indicator I have, that works mainly as an Overlay, will render bars on the main chart (which may be in panel 2, 3, etc.). These are scaled to around 15% of the max height, so requires OnCalculateMinMax to set that scale. On a few charts, this does not work. The bars appear full screen and are not scaled. On most charts, it works OK. I added 'Print' statements to 'Print(MaxValue);' at the end of my OnCalculateMinMax, and where it works fine, I see the values in the output window. Where is does not work, nothing gets printed and no errors are reported. It seems OnCalculateMinMax is not actually being called at all. I have added print statements to the very top, too, just in case of an error below. Nothing... All indicator settings between the 2 charts are the same and it is the same indicator on both charts. I have confirmed IsAutoScale is set to true in all cases.

    From what I can see, if you add 'public override void OnCalculateMinMax()' to your code, there is not a circumstance where it will not be called? in my case, it appears this is happening though.

    Any advice?
    Thanks.

    #2
    Hello pjsmith,

    thank you for the post.

    Because you noted this happens with some charts I just wanted to check does this still happen if you create totally new charts and ensure you are not using a template when you create them?

    The only reason I can think of where this would not be called would be if the chart autoscale was off, if you have that on it should be called when the chart calls it.

    We would likely need to see a working example of the problem in this case to further explore why that is happening, do you have a sample/test scenario that you can provide for me to try this?



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

    Comment


      #3
      Hi - It works fine on a new black chart. It's only a couple charts it happens one. It's obviously related to the way those charts are configured, but in all documentation, regardless, I could not find any notes that say OnCalculatminmax will not be called (as long as autoscale is on, which it is).

      Sorry - No simple test scenario and you are not going to be able to replicate the 5 panel chart. It's weird, because, without changing anything, once in a while it works, but then it stops... I'll look for a workaround, when I can. Thanks.

      Comment


        #4
        Hello pjsmith,

        Thanks for trying that.

        If new charts work, I believe the most simple way forward would be to try and rebuild just those charts and see if the problem continues. You may first try just saving a template, closing the chart and re creating it with the template to avoid having to rebuild it completely.

        If you continue to see a problem with those charts specifically it may be related to something applied there or a setting being applied. If that's the case you could try saving a template of one of those charts and I can try to give that a test. If the test requires multiple panels that could be arranged with a dummy indicator specific for testing that use case.

        I can also review the log/trace files if you note a time when this happened, you noted there were no errors however maybe there are other details in the trace during that time that can give a hint.


        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks. For some weird reason, it's started working again. It may (likely will) stop tomorrow without any further change. It seems it happens in the am, so I'm guessing it has to do with the amount of data on the chart (I chart with 0 days set). Just surprises me that OnCalculateMinMax simply appears to not be getting called, and regardless of anything else on the chart, that should not happen? (assuming autoscale is set to true, which it is). No errors appear in the log at the time.

          Comment


            #6
            Hello pjsmith,

            It could relate to the data, that would be a good item to test or to make one chart with 0 days and another with 1 day to see if that makes a difference. This is not documented as a reason for OnCalculateMinMax to not be called so if that relates to the problem we may need to report that.

            As far as I am aware the only reason this would not be called would be if it was not using autoscale in the chart. Otherwise if the platform has events happening this should be called, primarily for incoming new data but also for other reasons like resizing the window. When this happens if you resize the window is the method still not called?

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

            Comment


              #7
              is working today! So, will keep an eye on it. Resizing the windows had not effect as I had certainly tried that several times. the 'Print' statements in OnCalculateMinMax simple did not print and no errors reported in log. I will try and review next time it happens. Thanks.

              Comment


                #8
                Hello,

                Problem is back today. No idea why. OnCalculateMinMax is simply not running. Tried changing number of days to load, resized window, panels, etc., Nothing. Plots therefore take whole of window because there is no scale. I turned autoscale off, then on, same. As far as I can tell, there should never be a way this can happen, regardless of what I do, as long as autoscale is on? I will send you my logs and chart template. Perhaps you will see something I cannot.
                Last edited by pjsmith; 12-09-2019, 02:35 AM.

                Comment


                  #9
                  Hello pjsmith,

                  Are you applying custom items to the chart where you see this? If so did you remove those items and re test? This could be controlled by a custom item through its code which could explain why changing settings is not doing anything. Could to confirm if you are using any third party items on this chart currently?

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

                  Comment


                    #10
                    Good morning. Well, the indicator is a third party item, so err.... But, as explained, on a single chart with nothing else on, it will work. Also, the bahaviour varies from day to day with zero changes to my code or charts. I think the root cause is, OnCalculateMinMax is under some circumstances simply not being called, for whatever reason. As long as autoscale for that indicator is on, by design in Ninjatrader, this should not be possible? So I think looking at other stuff, whilst it may be a contributing factor, the real problem is perhaps somewhat more NT code, unless you are telling me there is some set of circumstances where with autoscale set on and an indicator is set as an overlay in a panel, onminmax will not be called. If there are such circumstances, please let me know so I can investigate further my side. If not, then I can only suggest it is logical to look at nt8 and see why it might not call oncalculateminmax?

                    Thanks.

                    Comment


                      #11
                      fwiw, this issue occurred again today, but I needed it resolved, and came up with a workaround. Confirmed, OCMM not being called again. So, just moved code from OCMM to within Onrender (so setting chartscale.maxvalue in there), and works perfectly. I guess there is some small additional overhead in doing this, but no other way around it I can see. So, if anyone else has this issue rendering indicators into panels other than '1', just set the scale in OnRender instead!

                      Comment


                        #12
                        Hello pjsmith,

                        As long as autoscale for that indicator is on, by design in Ninjatrader, this should not be possible?
                        Correct, at this point we would need to continue troubleshooting what else may be in the chart that could be affecting the result. As noted previously using the AutoScale is the only situation I know of that directly affects this override.

                        So I think looking at other stuff, whilst it may be a contributing factor, the real problem is perhaps somewhat more NT code, unless you are telling me there is some set of circumstances where with autoscale set on and an indicator is set as an overlay in a panel, onminmax will not be called.
                        As I don't have the full details of what items you are using in the chart or what settings were used we cant rule out something you are doing or something that is applied at this point. I would not expect this to be NT internal code otherwise we would likely see this come up more frequently or other users would begin to report similar occurrences. This likely relates to the situation or items being used in the chart. If you have other items applied besides the script you are testing that would be a good place to start further troubleshooting by removing those items.

                        I see that you worked around the issue by using OnRender, if you wish to continue troubleshooting from OCMM please let me know and we can continue that.


                        I look forward to being of further assistance.



                        JesseNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by trilliantrader, 04-18-2024, 08:16 AM
                        5 responses
                        22 views
                        0 likes
                        Last Post trilliantrader  
                        Started by Davidtowleii, Today, 12:15 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post Davidtowleii  
                        Started by guillembm, Yesterday, 11:25 AM
                        2 responses
                        9 views
                        0 likes
                        Last Post guillembm  
                        Started by junkone, 04-21-2024, 07:17 AM
                        9 responses
                        68 views
                        0 likes
                        Last Post jeronymite  
                        Started by mgco4you, Yesterday, 09:46 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X