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

Selfmade indicator compiles correctly but creates problems

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

    Selfmade indicator compiles correctly but creates problems

    My charts showed up with a strange sluggish behavior when I switched instruments. Windows Task Manager changed from showing NT Status Running to Status Not Responding for a few seconds and then back to Running again. See attached image. By deleting all indicators in the chart, and then adding one after the other I was able to pin it down to the attached self created indicator: EMAColorLinRegTest.

    I used previously employed methods to create it and it also compiles correctly. But something within the code must be incorrect. Can you please look over the code or test it somehow to determine what needs to be corrected to it runs smoothly.

    sandman
    Attached Files

    #2
    Hello sandman, and thank you for your question.

    While I have not tested your indicator source out, upon inspection I have noticed you have several statements with ambiguous logic. That is, you have some statements which reduce to

    if (a && b || c && d)

    I believe these should be

    if ( (a && b) || (c && d) )

    An example is on line 67 of your source. While C#'s order of operations will likely handle this ambiguity, it is generally good practice not to combine adding (logical or, ||) and grouping (logical and, &&) operations together.

    This said, as a debugging strategy, I would recommend the following :

    • Comment out the if and else-if blocks separately in the Condition SHORT and Condition LONG sections, e.g.

      /*
      if ( ...
      {
      ...
      }
      */
      /*
      else if (...
      {
      ...
      }
      */
    • Run this code, switching instruments
    • Uncomment one if or else if block at a time, re-run each time, switching instruments

    If you can repeat the above steps and report back with whether Ninja is being sluggish at each step, please let us know. If a block of code is performing sluggishly, comment it back out before moving on to the next step. You can turn an else if into an if by commenting out the word 'else' as follows : /* else */


    This will make it easier to track down exactly what is occurring.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Jessica,

      Thanks. I changed it accordingly and it looked good but matters in fact became worse. Made me think it's not a problem of the indicator but must be another issue. Suffice it to say I also reset the DB. But no go.

      Now when I open NT, it opens the Control Center and the Windows Task Manager shows it as Running, then Not responding, Running, Not responding, etc etc CPU usage goes up to 100% with nothing else running. See attached. I am stuck.

      Failing some instructions perhaps a remote Support person can look at it? Or I uninstall, and download NT newly.

      Help please.

      sandman
      Attached Files

      Comment


        #4
        Hello Sandman,

        The preceding was not meant as a solution, but rather as a method to help you find a solution. To clarify, when you say you changed the code, are you saying that the only live code inside OnBarUpdate is,

        Code:
              if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)
                   return;
        
                    if(BarsInProgress != 0) return;
        and that that is causing you to have 100% CPU usage?

        This should be equivalent to an empty OnBarUpdate. What happens when you delete the code in OnBarUpdate entirely and replace it with an opening and closing squiggly bracket?
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Jessica.

          I can't even get to that because NT does not even open up anymore. See last image I sent.

          sandman

          Comment


            #6
            Hello sandman, please perform the following steps so that you can re-open NinjaTrader reliably.

            • If NinjaTrader is still running, press the windows key on your keyboard (to the left of the space bar) and the letter r at the same time, and in the window that comes up, type this command

              taskkill /f /im NinjaTrader.exe
            • Delete your (My) Documents\NinjaTrader 7\workspaces\_Workspaces.xml file
            • On your desktop, right-click your NinjaTrader 7 64-bit shortcut, and change its target to the following :

              C:\Windows\System32\cmd.exe /c "start /high C:\PROGRA~2\NINJAT~1\bin64\NinjaTrader.exe"

            You should now be able to run NinjaTrader once more. Please let me know if this is not the case, if we can answer any other questions, and if you are able to run Ninja, what the results of your debugging are should I be able to be of further assistance in that area.
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Thanks Jessica.

              Step 1 and 2: Done.

              Step 3: Leads me to the attached window.
              Target location and Target are "grey"/not active/cannot be modified.

              What to do?

              sandman
              Attached Files

              Comment


                #8
                Hello sandman,

                To get around this, you can do the following :

                • Right click on your desktop -> New -> Shortcut
                • Browse to your C:\Program Files (x86)\NinjaTrader 7\bin64\NinjaTrader.exe file
                • Press OK
                • Press Next
                • Call this shortcut "NinjaTrader - High Priority"
                • Press Finish
                • Right click on your new NinjaTrader - High Priority shortcut -> Properties
                • Change its target to

                  C:\Windows\System32\cmd.exe /c "start /high C:\PROGRA~2\NINJAT~1\bin64\NinjaTrader.exe"
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  Got it, Jessica. Thanks. I've got to go for now but will do that within the next 24 hours and will let you know the outcome.

                  sandman

                  Comment


                    #10
                    Jessica,

                    I cannot find this file in this specific location:
                    C:\Program Files (x86)\NinjaTrader 7\bin64\NinjaTrader.exe file

                    - enclosed image shows my C drive folders and my Windows7 specifications with the hope that you can provide further guidance.

                    sandman
                    Attached Files

                    Comment


                      #11
                      Hello Sandman,

                      It appears you have a 32 bit operating system. That path should then be

                      C:\PROGRA~1\NINJAT~1\bin\NinjaTrader.exe

                      Or in longhand form

                      C:\Program Files\NinjaTrader 7\bin\NinjaTrader.exe

                      Please use these paths where appropriate in the above instructions.
                      Jessica P.NinjaTrader Customer Service

                      Comment


                        #12
                        Here is an update from my side Jessica.

                        1. NT opens and closes alright, and I can get into everything.

                        2. I changed the code in the original indicator I sent you by including more brackets:
                        else if
                        (

                        ( Falling(LinReg(BarsArray[1],9))
                        && LinReg(BarsArray[1],9)[0] > EMA(BarsArray[1],13)[0])

                        ||

                        (
                        Rising(LinReg(BarsArray[1],9))
                        && LinReg(BarsArray[1],9)[0] < EMA(BarsArray[1],13)[0])
                        )
                        and that seems to work fine. With that I mean it's doing what it is supposed to do. Still some oddity remains. I'll try to explain:

                        3. I closed NT, restarted it. Opened a chart with no indicators. Then went into edit mode for one of the standard NT indicators, an EMA. Compiled it. It does so with no problem whatsoever. Windows Task Manager shows NT "Running".
                        Then went into Edit mode of my indicator and compile it, it does so BUT Windows Task Manager changes for a few seconds from Running to Not Responding (and the whole desktop flickers for a second) until Compilation is complete. OK. Then I went back into Edit Mode for the standard EMA, and now the same happened i.e. after clicking "Compile" NT changes from Running into Not Responding for a few seconds. desktop flickers.

                        4. Same flickering and NT "Not Responding" happens when I have a small time frame (1,2,3 Minutes) chart open with the indicator running in it and then pushing F5. Lasts a few seconds and then everything works normally again. (The flickering/Not Responding does NOT happen when the indicator runs in a higher time frame e.g. 10, 15 or 60 Mins) and I push F5.

                        The modified cs file for the indicator is attached just in case.

                        Looking forward to hearing from you.

                        sandman
                        Attached Files

                        Comment


                          #13
                          Hello sandman, and thank you for further clarifying what is happening on your system.

                          This momentarily period of non-responsiveness whenever you are compiling is to be expected. What is happening, is that a C# compiler is being run in the background each time, for every C# file in your (My) Documents\NinjaTrader 8\bin\Custom folder . Even on a modern, fast computer, this is still processor and memory intensive.

                          Please let us know if there are any other ways we can help.
                          Jessica P.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by f.saeidi, Today, 01:32 PM
                          2 responses
                          4 views
                          0 likes
                          Last Post f.saeidi  
                          Started by alifarahani, 04-19-2024, 09:40 AM
                          9 responses
                          54 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by mmckinnm, Today, 01:34 PM
                          2 responses
                          5 views
                          0 likes
                          Last Post mmckinnm  
                          Started by Conceptzx, 10-11-2022, 06:38 AM
                          3 responses
                          60 views
                          0 likes
                          Last Post NinjaTrader_SeanH  
                          Started by traderqz, Today, 12:06 AM
                          9 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Working...
                          X