NexusFi: Find Your Edge


Home Menu

 





Reducing CPU load of NinjaTrader


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Fat Tails with 14 posts (17 thanks)
    2. looks_two aslan with 5 posts (5 thanks)
    3. looks_3 Tarkus11 with 3 posts (2 thanks)
    4. looks_4 Big Mike with 3 posts (0 thanks)
      Best Posters
    1. looks_one RJay with 3 thanks per post
    2. looks_two Fat Tails with 1.2 thanks per post
    3. looks_3 aslan with 1 thanks per post
    4. looks_4 Tarkus11 with 0.7 thanks per post
    1. trending_up 16,293 views
    2. thumb_up 29 thanks given
    3. group 7 followers
    1. forum 37 posts
    2. attach_file 3 attachments




 
Search this Thread

Reducing CPU load of NinjaTrader

  #21 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

Got this answer from Dierk who kindly responded to my question:


The Draw() methods create objects which are redrawn whenever a chart is repainted which is triggered by logic below. *)

Obviously the Draw() methods in your code would be called whenever OnBarUpdate() is triggered which could be down to the tick (COBC=false).


*) However, here is some info: IndicatorBase.Plot() call frequency is primarily impacted by the chart update frequency. Although there might be additional situations where the chart (and indicators) would require repainting.

As far as I have observed it is the repainting of the objects that consumes CPU power. If you cover a chart, it will not be repainted and the CPU load is quickly reduced.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
43 thanks
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
  #22 (permalink)
 futuretrader 
Como Italy
 
Experience: Intermediate
Platform: Ninjatrader, customized
Trading: ES
Posts: 525 since Feb 2010
Thanks Given: 471
Thanks Received: 643


Fat Tails View Post
As far as I have observed it is the repainting of the objects that consumes CPU power. If you cover a chart, it will not be repainted and the CPU load is quickly reduced.

Yes, that corresponds to my experience too. I minimize any chart I'm not looking at. You can experiment with all this using market replay, too.

Reply With Quote
Thanked by:
  #23 (permalink)
 Tarkus11 
East Coast
 
Experience: Beginner
Platform: Ninja
Trading: ES, NQ
Posts: 124 since Apr 2010
Thanks Given: 55
Thanks Received: 80



Fat Tails View Post
Got this answer from Dierk who kindly responded to my question:


The Draw() methods create objects which are redrawn whenever a chart is repainted which is triggered by logic below. *)

Obviously the Draw() methods in your code would be called whenever OnBarUpdate() is triggered which could be down to the tick (COBC=false).


*) However, here is some info: IndicatorBase.Plot() call frequency is primarily impacted by the chart update frequency. Although there might be additional situations where the chart (and indicators) would require repainting.

As far as I have observed it is the repainting of the objects that consumes CPU power. If you cover a chart, it will not be repainted and the CPU load is quickly reduced.


Looking through some older posts - again, thanks for this!

I have removed most of the Draw statements from my indicators and what used to be big spikes in my 6-core 4.2Ghz CPU has calmed down even with news events.

While I like the aesthetics of clouds created with DrawRegion, it clearly created performance issues along with some other Draw commands.

Reply With Quote
Thanked by:
  #24 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Tarkus11 View Post
Looking through some older posts - again, thanks for this!

I have removed most of the Draw statements from my indicators and what used to be big spikes in my 6-core 4.2Ghz CPU has calmed down even with news events.

While I like the aesthetics of clouds created with DrawRegion, it clearly created performance issues along with some other Draw commands.

You can also limit the draw objects by using a lookback period from now and only draw them within that lookback period. You will then have them on today's chart, but not on the chart section a few days ago.

Started this thread Reply With Quote
Thanked by:
  #25 (permalink)
 Tarkus11 
East Coast
 
Experience: Beginner
Platform: Ninja
Trading: ES, NQ
Posts: 124 since Apr 2010
Thanks Given: 55
Thanks Received: 80

After observing this for a day and not having any "Not Responding" issues on the charts, I can say IMO this Draw issue is so severe that NT should include a warning on their use.

Fri was not as wild as Mon, and there were no big news announcements, but so far, so good...

In the past I have included some "cloud" coloring code in my indicators for aesthetics (and it also removes any visual ambiguity in a chart when sending an image of it), but the performance impact on live charts is horrendous.

So I now bracket that logic with a bool, so I can turn it on/off as a parameter. That way I can turn it on during off-time or when capturing an image, but leave it off while the chart is being updated.

Tweaking the efficiency of the Draw routines and the ability to use multi-cores during live updates is what I would put on the top of the "to do" list, but they probably are at NT anyway....

Reply With Quote
  #26 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Tarkus11 View Post
After observing this for a day and not having any "Not Responding" issues on the charts, I can say IMO this Draw issue is so severe that NT should include a warning on their use.

Fri was not as wild as Mon, and there were no big news announcements, but so far, so good...

In the past I have included some "cloud" coloring code in my indicators for aesthetics (and it also removes any visual ambiguity in a chart when sending an image of it), but the performance impact on live charts is horrendous.

So I now bracket that logic with a bool, so I can turn it on/off as a parameter. That way I can turn it on during off-time or when capturing an image, but leave it off while the chart is being updated.

Tweaking the efficiency of the Draw routines and the ability to use multi-cores during live updates is what I would put on the top of the "to do" list, but they probably are at NT anyway....

If you use indicators, which draw clouds or colored channels, you should use them in setting CalculateOnBarClose = true. This should avoid a freeze.

I also use a bracket to a exclude the drawing of regions and rectangles. I do not have a separate Boolean, but use the opacity.. If it is set to 0, the part of the code with the Draw() methods is not executed, here an example from the TWAP V36

 
Code
if (Opacity1 != 0)
{
     DrawRegion("upper1"+ startBar, sessionBar-1, 0, UpperBand1, SessionTWAP, Color.Transparent, InnerAreaColor, Opacity1);
     DrawRegion("lower1"+ startBar, sessionBar-1, 0, SessionTWAP, LowerBand1, Color.Transparent, InnerAreaColor, Opacity1);
}

Started this thread Reply With Quote
Thanked by:
  #27 (permalink)
 gkinlaw 
etown,nc
 
Experience: Intermediate
Platform: ninjatrader
Broker: amp/zen
Trading: cl, es
Posts: 11 since Oct 2009
Thanks Given: 5
Thanks Received: 1

I had freeze/slow problems all week with the increased volume in 6e. I have a quad core, 3g mem... I reinstalled ninja, went to empty workspace and created a new chart and it was still slow. When I loaded up indicators on the chart it slowed up more. The cpu meter would max out on approx 25% when normally I have cpu usage of 3-6%.

Also the cursor would not respond quickly moving across the charts. Can't trade if you think you might be lagging the real time market.


No severe problems like this prior to this week. And all goes back to normal when volume drops off.. My computer guru buddy heard that there is a problem with quad cpu's and nt7. Anyone else have info on this?? I cut my processors down to 2 and now I get normal cpu spikes above 25%. That was late day on Friday so I'll have to wait until Monday to see if it works

Other suggestions I have read on blogs today: update video drivers, delete old version of .net, repair database, delete mdb.....

Reply With Quote
  #28 (permalink)
 Tarkus11 
East Coast
 
Experience: Beginner
Platform: Ninja
Trading: ES, NQ
Posts: 124 since Apr 2010
Thanks Given: 55
Thanks Received: 80


gkinlaw View Post
I had freeze/slow problems all week with the increased volume in 6e. I have a quad core, 3g mem... I reinstalled ninja, went to empty workspace and created a new chart and it was still slow. When I loaded up indicators on the chart it slowed up more. The cpu meter would max out on approx 25% when normally I have cpu usage of 3-6%.

Also the cursor would not respond quickly moving across the charts. Can't trade if you think you might be lagging the real time market.


No severe problems like this prior to this week. And all goes back to normal when volume drops off.. My computer guru buddy heard that there is a problem with quad cpu's and nt7. Anyone else have info on this?? I cut my processors down to 2 and now I get normal cpu spikes above 25%. That was late day on Friday so I'll have to wait until Monday to see if it works

Other suggestions I have read on blogs today: update video drivers, delete old version of .net, repair database, delete mdb.....


You should be able to test before Monday by using replay data under File/Download Replay Data...

I have a 6-core CPU but NT single-threads live charts anyway. Since turbo-mode of the chip can boost 3 cores to 4.2Ghz for those type of apps, I force NT to use the faster cores by setting the startup property of my NT-64bit icon (got this from a user on the NT forum)

C:\Windows\System32\cmd.exe /C start "NinjaTrader 7" /HIGH /AFFINITY 0x7 "C:\Program Files (x86)\NinjaTrader 7\bin64\NinjaTrader.exe"

This sets NT to High Priority and the Affinity to use the 1st 3 cores (doesn't matter which one since all 3 are turbo-boosted).

If your indicators use a lot of Draws you might want to exclude them if you can. Also try the suggestion of minimizing to the Taskbar charts you don't constantly watch to lighten the re-draws that the CPU has to perform.

I am not sure if NT is offloading screen updates to the GPU using WPF - I have a decent video card (not great, but good enough) and I would hope it is being used to take some stress off the CPU.....

EDIT:

I guess not

https://forum.ninjatrader.com/showthread.php?t=11898

Will NT 7's charts be based on Windows Presentation Foundation (WPF) or WinForms?

It will be based on WinForms.

Reply With Quote
  #29 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,446 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,608


gkinlaw View Post
Ihe cpu meter would max out on approx 25%

If you have a quad core CPU, then this indicates NinjaTrader's single-threaded design is the culprit. For charting, NinjaTrader can only use one CPU thread at a time, last time I checked.

Usually this is due to an indicator. If you run NinjaTrader with no indicators, you shouldn't see this problem.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #30 (permalink)
 gkinlaw 
etown,nc
 
Experience: Intermediate
Platform: ninjatrader
Broker: amp/zen
Trading: cl, es
Posts: 11 since Oct 2009
Thanks Given: 5
Thanks Received: 1



Big Mike View Post
If you have a quad core CPU, then this indicates NinjaTrader's single-threaded design is the culprit. For charting, NinjaTrader can only use one CPU thread at a time, last time I checked.

Usually this is due to an indicator. If you run NinjaTrader with no indicators, you shouldn't see this problem.

Mike


Here's an image of the task mgr with 2 cpu's running, I get spike's now instead of capping off at 25%. Also yesterday I found that I was recording data in Jan 1. and I cut that off. Bet that used up some cpu.

thanks for you replies!!

Reply With Quote




Last Updated on November 8, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts