Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StrategyAnalyzer clearing output window without ClearOutpuWindow call

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

    StrategyAnalyzer clearing output window without ClearOutpuWindow call

    Hi,

    I'm fairly new to the platform. The output window is being cleared every time I run the strategy analyzer. Obviously this makes it hard to debug things since the print logs just disappear when the run is complete. I had run the ClearOutputWindow in a strategy script a few weeks ago, but my current strategy does not have that call in it. Can someone help or point me at other places to look? I saw this old thread which says this should not occur.



    Thanks.

    #2
    Hello mohawkTrader, thanks for your post.

    It sounds like ClearOutPutWindows is still being called somewhere either in the script you are working on or another script. If you have Visual Studio (VS) installed, you can click the Visual Studio icon at the top on a NinjaScript editor to open up the custom project. Once opened in VS, you can search the project for the syntax "ClearOutputWindow" to see where/if it is being called anywhere in another script. I believe the Windows search function will work in a similar way, navigate to Documents\NinjaTrader 8\bin\Custom and search for "ClearOutputWindow".

    I look forward to hearing of your results.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hey thanks. I commented it out of a two other strategy scripts and that fixed the issue. I guess I thought that only the current strategy script (run in the analyzer) would affect the output window as that's the code that's executed. Not sure why this is the case, but I can look at the output now either way. Thanks!

      Comment


        #4
        Hi mohawkTrader, Im glad you were able to sort that out.

        See the NinjaScript lifecycle help guide page. There are times during runtime of NinjaTrader where the OnStateChanged method is run for all scripts compiled within the NT custom DLL. This is to populate UI lists and other internal housekeeping. The logic was likely running in the other scripts due to this principle.

        All the best wishes!
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thank you. This makes a lot more sense now.

          Comment


            #6
            Originally posted by NinjaTrader_ChrisL View Post
            Hi mohawkTrader, Im glad you were able to sort that out.

            See the NinjaScript lifecycle help guide page. There are times during runtime of NinjaTrader where the OnStateChanged method is run for all scripts compiled within the NT custom DLL. This is to populate UI lists and other internal housekeeping. The logic was likely running in the other scripts due to this principle.

            All the best wishes!
            Thank you Chris.
            Please mark this behavior as a BUG!
            I wasted 2 days of programming to find out why i see blank screen on my output windows when debugging.
            Apparently , i Installed a lot of scripts on my dev machine and there was a lot of "ClearOutputWindow()" on EVERY onStateChange of them.
            When starting to mark out the code, things started to be seen.
            WHY SHOULD OTHER SCRIPTS SHOULD INFLUENCE THE ENGINE WHEN RUNNING IN STRATEGY ANYLYZER OR WORSE IN REALTIME ????!!!
            Terrible bug that waste me 2 days of programming.
            Please fix it ASAP.
            Thx and Regards.

            Isaac.

            Comment


              #7
              Hello Isaac,

              ClearOutputWindow() is going to clear the output window when called, and this is not a bug.

              If you are calling ClearOutputWindow() in OnStateChange() when State is State.DataLoaded, this won't be called when opening the UI. If you put this in State.SetDefaults or State.Terminated it will be called when opening the UI.

              Meaning call this in State.DataLoaded and you won't an issue. Stop calling this in State.SetDefaults or State.Terminated.

              Please study this help guide page that talks about the NinjaScript states.


              It's up to your logic to call this intelligently.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello Isaac,

                ClearOutputWindow() is going to clear the output window when called, and this is not a bug.

                If you are calling ClearOutputWindow() in OnStateChange() when State is State.DataLoaded, this won't be called when opening the UI. If you put this in State.SetDefaults or State.Terminated it will be called when opening the UI.

                Meaning call this in State.DataLoaded and you won't an issue. Stop calling this in State.SetDefaults or State.Terminated.

                Please study this help guide page that talks about the NinjaScript states.


                It's up to your logic to call this intelligently.
                Thank you Chelsea, but I think you didn't understand me.
                I'm not referring what ClearOutputWindow() Do!
                I'm referring to the fact that in Strategy Analyzer , when i'm loading one Strategy, If i have in the same folder/folders other registered Strategies that NT8 is aware of, say 1000 other
                Strategies, if in each one of them there will be ClearOutputWindow() in the Setdefault or Configure state, they ALL will influence the Ninjascript Output windows and clear it even though
                I'm examining only my own strategy and trying to debug it and look results in the output windows.
                It's CRAZY!
                Think that in Visual Studio when I'm debugging my .cs code file in the debugger and looking in the output window, the outcome will be decided by some others .cs files that seats in the same folder of my .cs file ???!!! Even when I'm not touching them and not loading them to debug and to execute?
                Now I have to search all my 1000 strategies in my whole solution and search ClearOutputWindow() and comment it to be able to debug my own strategy, and when i will finish i need to go back to whole 1000 strategies that i commented before and uncomment it back???!!!
                Sorry, this is a MAJOR bug.
                And I'm a Senior Programmer (.net and C#) - (even if i wasn't).
                Please move this point to your developers and let them decide.
                Thx.
                Isaac.

                Comment


                  #9
                  Isaac,

                  NinjaTrader has to create an instance of each script to be able to list them and their parameters.

                  This is why State.SetDefaults is called for every strategy. Its necessary to do if you want to be able to see them in the Strategies window.

                  Don't put ClearOutputWindow() in State.SetDefaults and this behavior will not occur.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Isaac,

                    NinjaTrader has to create an instance of each script to be able to list them and their parameters.

                    This is why State.SetDefaults is called for every strategy. Its necessary to do if you want to be able to see them in the Strategies window.

                    Don't put ClearOutputWindow() in State.SetDefaults and this behavior will not occur.
                    Thank Chelsea.
                    Again.
                    As a Senior Programmer and as a basic user and as a smart user - User SHOULD NOT NEED to know this post to don't put ClearOutputWindow() in State.SetDefaults.
                    Every respectable software SHOULD NOT let influence for a script code that is not loaded and activated to influence OTHER code.
                    This is MAJOR bug that SHOULDN'T be there!
                    It take me 2 whole days to crack my head and to search here till i found this. AND THIS IS BAD.
                    The solution for this is easy! when the interpreter loads the code of the scripts to list them in the list - it only need to delete/ignore the ClearOutputWindow() command of the non active scripts.
                    Simple.
                    Move it to your developers please. Thx.

                    In another matter , I would glad if you address my other much more big problem regarding BackTesting/Optimization(TickReplay On) Vs. PLAYBACK.
                    here :https://ninjatrader.com/support/foru...for-strategies
                    or here:


                    This problem is more serious and more urgent , and it's regarding your great video of the diff between backtest/playback/realtime.
                    Thx Chelsea.

                    Comment


                      #11
                      Hello IsaacBillion,

                      Any developer that is creating scripts for the NinjaTrader Platform does need to know about the NinjaScript Lifecycle and where is appropriate and not appropriate to place code.
                      It is the responsibility of the developer to understand the code they are writing and how NinjaScript works.

                      Always be encouraged to contact the Engineering Support team if you are not understanding how the NinjaScript Lifecyle works and where code is appropriate to place.

                      Below is a link to a forum post that discusses the NinjaScript LifeCycle, and does printing in OnStateChange(), including when State is State.SetDefaults.



                      I personally have used clearing the output window in constructors and in State.SetDefaults, as the test script I was creating was intentionally showing information for a specific instance identified by a generated ID. Blocking the method during State.SetDefaults would have prevented my ability to do so, and thereby I would not have been able to properly assist in analyzing the behavior of clients script.

                      However, at your request, I will forward your request for the Ninjascript Development team to consider disabling the functionality of this ClearOutputWindow() method.

                      Once I have an ID for this request I will post in this thread for future reference.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Chelsea !
                        I sure agree that every serious developer that needs to deep dive to complex code will need to know perfectly the lifecycle of the software. like in WPF, XAMARIN, asp.net , asp.net core etc.
                        but not for this BASIC thing like clearing the screen.
                        look also for your colleague in your post you attached (thank you for that! very important post! ) in his first answer there. He thinks like me.
                        Thanks very much.
                        How to reach out the Engineering Support? (email? this forum?)

                        Looking forward for your reference to my other problem.
                        Thx very much.
                        Isaac.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by briansaul, Today, 05:31 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post briansaul  
                        Started by fwendolynlpxz, Today, 05:19 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post fwendolynlpxz  
                        Started by traderqz, Yesterday, 12:06 AM
                        11 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by PaulMohn, Today, 03:49 AM
                        0 responses
                        8 views
                        0 likes
                        Last Post PaulMohn  
                        Started by inanazsocial, Today, 01:15 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Jason  
                        Working...
                        X