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

Performance/Hang Issues

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

    Performance/Hang Issues

    I've been testing auto strategies but the platform suddenly hangs/ doesnt respond but I see the orders getting executed on the background (hear the entry/exit sound messages)

    Any way to find the root cause for the hang issue?

    #2
    Hello ark321,

    Thanks for your post.

    If you are hearing order confirmation sounds, it is likely that your condition to place the order is stuck evaluating to true and the exit order is happening right away, causing an endless entry/exit loop.

    Could you confirm if your strategy is encountering an endless loop?

    Or, are you hearing the order confirmation sounds occasionally and the strategy is working as expected but the platform is frozen?

    To see if the strategy is encountering an endless entry/exit loop, you could change the exit method as a test by removing the exit so that the strategy does not exit the position. Or, you could move the exit farther away from the entry order to ensure it does not get filled immediately after entering a position.

    Note that you could also consider including BarsSinceEntryExecution or BarsSinceExitExecution to have the strategy wait a certain number of bars before entering/exiting a position.

    See the help guide documentation below.
    BarsSInceEntryExecution: https://ninjatrader.com/support/help...yexecution.htm
    BarsSinceExitExecution: https://ninjatrader.com/support/help...texecution.htm

    I look forward to further assisting.


    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      It is not a looping issues.
      hearing the order confirmation sounds occasionally and the strategy is working as expected but the platform is getting frozen.

      Comment


        #4
        Hello ark321,

        Thanks for your note.

        Please test running the SampleMACrossOver strategy which comes default with NinjaTrader to see if the same behavior occurs.

        If you do not see the same behavior when testing the SampleMACrossOver strategy, this likely means there is something in your code that is causing the behavior you are reporting.

        To isolate where the issue in your script is coming from, debugging steps would need to be taken.

        To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        Please let me know if I may further assist
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          The issue is not with the strategy nor execution. The strategy is executed fine and as expected and I see the prints in output window. But the platform is getting frozen while the strategy gets executed. How do I debug this issue?

          Comment


            #6
            Hello ark321,

            Thanks for your note.

            If you do not see the same behavior occur when testing the SampleMACrossOver strategy that comes default with NinjaTrader, there is likely some code in your script that is causing the freezing issue to occur.

            When working with any issue, it is important to take steps to isolate the issue so that the exact line causing the behavior can be found. This is a process of elimination and a process of debugging by adding prints.

            First, it is great to create a copy of the script so that the original work is kept safe. Below is a link to a video that demonstrates making a copy of script.
            https://www.youtube.com/watch?v=BA0W...utu.be&t=8m15s

            Once the copy is created, the copy can be modified in any way without losing the original work.

            The next step is to start commenting out code.

            It's helpful to think about when the error is occurring to target areas, and comment code from everywhere else quickly. If at any point after removing some code, the error stops, add the last removed item back.

            If the error is occurring while the script is loading, the issue is likely somewhere in OnStateChange(). In this situation its best to remove any logic in OnBarUpdate, remove any custom methods and classes, and remove as many properties as possible, while still being able to reproduce the error.

            If the error is occurring when saving a template, the issue is likely with a private or public variable declaration. First, remove all logic leaving the variable declarations behind. (Empty State.Configure, State.Dataloaded, State.Historical, OnBarUpdate, OnMarketData, and remove any custom methods.) Then start removing the variables one by one and testing until the error stops. When the error stops add the last removed item back. Ensure that this item is private or property serialized or using the Browsable(false) attribute. (More about the Browsable attribute below)

            If the error only occurs while the strategy is trading, this is likely a run time method. For this its best to use prints to understand the behavior.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            5 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            13 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,982 views
            3 likes
            Last Post jhudas88  
            Working...
            X