Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hmm...not that I do not like the profit, but this looks a bit weird...

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

    Hmm...not that I do not like the profit, but this looks a bit weird...

    Just take a good look and you see, and yes this was at the end of the chart. I have seen this now a few times, and was wondering if the data cannot catch up with the data from the exchange? Are there 2 data streams hitting the chart? I did close and re-open, so I closed Ninja and re-opened the desktop, and than it was good again, but is there something I need to do to prevent this?

    This desktop is running on an AWS server, enough memory, CPU < 40% and no interaction. (this means, I have a robot programmed and it is doing it's job)

    Click image for larger version

Name:	image.png
Views:	173
Size:	31.2 KB
ID:	1258011​

    #2
    Hello tullips,

    Thank you for your post.

    ​What I believe you are experiencing according to this behavior is 'rendering delay' which can occur when your platform is not able to calculate the incoming information fast enough to keep up with the live market due to several factors such as having too many workspaces open, inefficient 3rd party indicators applied, or a workspace this is too complex for your computer's hardware to keep up with with higher market volatility.

    This can be seen by by reviewing the Ask, A: and Bid, B: prices in Chart Trader to the Last price displayed on the y-axis

    This is due to the Ask and Bid prices being displayed in Realtime and the last price becomes delayed due to the aforementioned above as it is displayed after all the calculations have taken place.

    I do see that you have several custom add-ons installed which may be contributing to this behavior:I would first recommend reviewing the performance tips page for NinjaTrader 8 to optimize your platform:Also, to see what (if any) NinjaScript items may be contributing to the symptoms, please open the NinjaScript Utilization Monitor:
    • Control Center > New > NinjaScript Output
    • Right-click within the NinjaScript output window > Select 'NinjaScript Utilization Monitor...
    • This window will begin to populate with NinjaScript items in order of time spent processing
    • Let this window populate for at least a few minutes then send me a screenshot of it's contents
      • To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.
      • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.
    Spencer F.NinjaTrader Customer Service

    Comment


      #3
      I think the key is when you say CPU < 40% - that's very high. I would never want my NT to have CPU usage nearly that high. There's no magic number, but if it were 40% on average that would imply that there are many times it's swamped and can't keep up because if the average is 40% some are more. Let's hope you have CPU < 10% almost all the time and then fast market conditions can be rapidly responded to with lots of excess capacity.

      Furthermore, if this AWS server has more than one core allocated to it, you could have one thread that is 100% busy and backlogged, yet there are other cores that are not busy. Such an arrangement could easily yield a total CPU usage that is low yet one core/thread is completely swamped.
      Last edited by QuantKey_Bruce; 06-29-2023, 08:00 AM.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Awesome answers guys, really appreciate this. I also have on the same server TradeStation running, but I am running this side by side now for a long time, and it was just in the last few days when I was seeing this behavior. In the aftermarket hours I am not seeing a hot CPU, this is only at the open, or the FED meeting, some event like that.

        I have 8 charts in total, all with only 1 indicator/robot running. But I will also see if it is doing some things too much. (I programmed the robot, but I am really new in C# (just 4 months now), but not in programming other languages, this I do >30 years, I am an old fart programmer .

        Here the screenshot from the performance monitor and the task manager. I did see the AntiMalware services eating a big portion of my memory. But it never went above 50%

        Click image for larger version

Name:	image.png
Views:	163
Size:	60.2 KB
ID:	1258324​

        Click image for larger version

Name:	image.png
Views:	176
Size:	26.7 KB
ID:	1258323

        Comment


          #5
          Hello tullips,

          Thank you for your post.

          From your screenshot, I see that you have an indicator that is most likely causing this behavior resulting in rendering delays.

          I see that the 'ADSFomo' indicator is taking exponentially more time to calculate then anything else in your workspace.

          This can cause your platform to not be able to keep up with the current market if this is taking too much time to calculate the information and then be able to render it on your chart window.

          As a test, I recommend removing this indicator from your workspace and reloading all Historical Data in your charts by right-clicking and selecting 'Reload All Historical Data' within your chart window.

          Also for your reference, I have included a link below to our Performance Tips page for NinjaTrader 8:
          Please let me know the results of this test.​
          Spencer F.NinjaTrader Customer Service

          Comment


            #6
            550 MB of RAM is basically nothing. You may be able to optimize your indicator to run faster. You would have to consider what it's doing in there and if there's a better way.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Helpful tips, and yes, the ADSFomo indicator is the robot, the only indicator that is 'working', and it is really working well, so what I will do is (locally) comment out parts and see what is using the CPU the most. I am a fan of speed, and I was always keen for my products to run fast. This is how my website was built and this made me successful.

              I am using TradeStation to write out some info (text files) and reading them back into Ninja and TradeStation as well (the global memory they have is finical, and made it unstable, using text files was the better option.

              But IO operations are heavy on the machine, I know this. I use Visual Studio as my editor, and I did see there is a way to look for performance in there as well. I will dig deep and will provide some answers that might help others as well.

              Thanks again -- Ronald (founder SDC.COM)


              Comment


                #8
                Because of you guys, I was trying to cut the usage. The tip from Bruce 'What is it doing there' gave me the inspiration to think about it.

                DO I NEED VISUALS FOR A ROBOT, NOPE!!!

                So, I made this as an option to kill the visuals and here are the results on a 5-minute run at 10:30 am with now even more charts open, in total 10 (to make it more dramatic) , the first WITH the visuals on.

                Click image for larger version  Name:	image.png Views:	0 Size:	42.3 KB ID:	1258454

                And this with all the visuals hidden, and it became more....so now it is a bit confusing, the robot does not need the visuals, but by hiding them it was now even taking more time, I will now dig deeper and will also look for an apples-to-apples comparison. As I am not really sure what is considered high. 57 seconds on a 5 minutes run....perhaps it is....but perhaps not. Are there any rules for this? (b.t.w. the CPU did decrease the average load by about 2% without the visuals)

                Click image for larger version  Name:	image.png Views:	0 Size:	46.0 KB ID:	1258455​

                Attached Files

                Comment


                  #9
                  Well, you can't directly compare those two "total time" values unless you were absolutely diligent in only allowing each to run for 5 minutes exactly. If that isn't to the second that you cut if off (exactly 5 minutes) then you're not really comparing anything meaningfully.

                  One way to interpret "57 seconds for a 5-minute run" is that this specific indicator used fully 57 seconds out of 300 total seconds, or 1/5 of a virtual core on average. Or, looked at another way, the one indicator is responsible for 20% of CPU usage on a single virtual core. That's just rounded, and an average - it could be that it's completely 100% cpu for brief periods and then idle other times.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Thanks Bruce, and yes, I was diligent with the 5 minutes run using a stopwatch. I am comparing now appels to apples, and wow, yes, there are a lot of things I need to do, which is fun as I like programming. Keeps my brain busy and keeps me out of trouble.

                    I will keep you guys posted, but I think this could turn into some weeks from now....

                    Comment


                      #11
                      Hello again. I found the bugger. It was trying to get the current positions too many times...this was done out of paranoia as once I was relying on my accounting, and this went wrong with me ending up with >40 YM contracts in 1 minute. (Well, all must go through a little pain sometimes, but I recovered)

                      I do believe my way of getting my positions is a bit 'funky' to say the least, but in indicators I did not find an uncomplicated way (unlike in strategies) to get my current positions for the current symbol I am trading.

                      I also looked online and, in the forum, and did not see an uncomplicated way.

                      I would like to be able to start the chart and add the indicator/robot and it should know it is not flat and has, for example, 2 ES contracts already in it, and can take over the trading.

                      My solution to this problem is taking all the positions from my account, adding it into an array, split up by space, and checking for symbol = current symbol. I had this done in OnStateChange() and that was causing the program to take away lots of CPU time. Now I am more careful and got about a 100 times improvement!!

                      All thanks to you guys!!

                      My code (a bit simplified to explain) is like this.

                      Code:
                              // Getting my positions from myAccount
                              private void getMyPositions(string sender="")
                              {
                                  var tmpArray = myAccount.Positions.ToArray();   // put all positions from this account into an array
                      
                                  if(sender != "") Print("getMyPositions " + sender);    // good for debugging ;)
                      
                                  double temp;
                                  var myString = "";                              // in here we put in the content from the array
                                  char[] delimiterChars = { ' ' };
                      
                                  if (tmpArray.Length > 0) // now we know there are some positions in this account
                                  {
                                      myPositions = 0;                        // we reset it first
                                      foreach (var item in tmpArray)
                                      {
                                          myString = item.ToString();
                                          if (myString.Contains("'" + Instrument.FullName)) // here we look for the symbol to match
                                          {
                                              string[] words = myString.Split(delimiterChars);    // this is putting the string into an array using space as delimiter                                                                            
                                              myPositions = int.Parse(words[4].Substring(9).ToString());
                                          }
                                      }
                                  }
                              }
                      ps I found the Zombie9 pack, he amazed me with his TickHunter as this has over 25'000 lines of code but shows no substantial impact on performance, as I am old school and believed the more line of code you have the slower the program, but he proved that this is not true. He has something called Zombie9AccountInfo in there and I will look if I can use his methods. But if you have a better solution and advice I am listening carefully
                      Last edited by tullips; 07-03-2023, 02:43 AM.

                      Comment


                        #12
                        The words from Bruce (QuantKey_Bruce) gave me the right inspiration to cut down the performance by a lot. I did again the same 5-minute run on 8 charts,

                        Click image for larger version  Name:	image.png Views:	0 Size:	171.0 KB ID:	1259081
                        It does the same work as before. and yes, I can even reduce the ChartObject 'fixed text' as well, but I believe I reached a goal to reduce the CPU usage by a lot. I was going back and forwards, fixing something that created more bugs, and the more I tried to fix, the deeper the mess became. Then I went back to the original and was thinking 'What do I really need every millisecond' and this suddenly gave me the inspiration to change the code and have it only calculate each 500 milliseconds. I just made a very simple timer, setting a Boolean. and that is it....and the CPU is now <15%

                        The code
                        Code:
                        private DateTime tradingTimer = DateTime.Now;
                        private bool isTrade;
                        
                        protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
                                {
                        
                        DateTime currentTime = DateTime.Now;  
                        
                                    if (isTrade == true)
                                    {
                                        var diffOfDates = currentTime - tradingTimer;
                                        if (diffOfDates.Milliseconds > 500)
                                        {
                                            tradingTimer = DateTime.Now;
                                            isTrade = false;  // reset the timer                  
                                        }
                                    }
                        }
                        Last edited by tullips; 07-05-2023, 12:41 PM.

                        Comment


                          #13
                          There's a nice free indicator you can use to check for chart delay here: https://support.leelootrading.com/kb...asure-lag.aspx

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by LanceFulk, 12-06-2024, 06:28 PM
                          2 responses
                          30 views
                          0 likes
                          Last Post LanceFulk  
                          Started by BarzTrading, Today, 04:35 PM
                          1 response
                          8 views
                          0 likes
                          Last Post BarzTrading  
                          Started by devatechnologies, Today, 04:06 PM
                          2 responses
                          8 views
                          0 likes
                          Last Post devatechnologies  
                          Started by Haiasi, 12-07-2024, 09:58 PM
                          2 responses
                          23 views
                          0 likes
                          Last Post Haiasi
                          by Haiasi
                           
                          Started by FBraun, Today, 01:34 PM
                          2 responses
                          15 views
                          0 likes
                          Last Post FBraun
                          by FBraun
                           
                          Working...
                          X