Can this be done? Detect if indicator is running in front-loaded workspace - NinjaTrader Programming | futures io social day trading
futures io futures trading


Can this be done? Detect if indicator is running in front-loaded workspace
Updated: Views / Replies:546 / 8
Created: by FBJS Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Can this be done? Detect if indicator is running in front-loaded workspace

  #1 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received

Can this be done? Detect if indicator is running in front-loaded workspace

As you know, NinjaTrader is set up so that all charts/indicators that are open and running will eat up CPU time, whether they are currently being displayed or not. So if you have 4 charts in one workspace and 4 charts in another workspace, all 8 charts will eat up CPU cycles, even though only 4 are showing.

Is there some way to write C# code inside an indicator to detect if it is running in the currently open workspace? If so, you could short-circuit the calculation code to only run if the chart is being displayed in the current front-loaded workspace, thereby saving CPU cycles. I've already found a way to do this with minimized charts (using the Windows.Forms library), but I'm just wondering if there's some way to hook into NT's code (supported or not) that will allow you to do a check to see if a workspace is currently being displayed on-screen. Actually, I can think of a hack that might work for me if I could do something as simple as just checking the name of the current workspace that a chart window is running in, whether it is currently front-loaded or not. Is there some way to do this?

Thanks!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


Or you could just close the other workspace and then it would not use any CPU

Math. A gateway drug to reality.
Reply With Quote
 
  #4 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


FBJS View Post
As you know, NinjaTrader is set up so that all charts/indicators that are open and running will eat up CPU time, whether they are currently being displayed or not. So if you have 4 charts in one workspace and 4 charts in another workspace, all 8 charts will eat up CPU cycles, even though only 4 are showing.

I think you would be far better served seeing which indicator(s) are consuming most cpu time and either losing or optimising them.

For historical reasons (largely 6.5) Ninja gets a pretty unfair press, I can prove it easily as I run 4-7 concurrent workspaces with multiple charts and loads of home grown heavy drawing indicators in all of them. On my bog standard HP 8core/8Gb i7 it ticks over with 1-2% of cpu and only hits 6-7% under a fast market load, despite of course itself being uselessly single threaded, now that is a shame.

E.g. As an example if you have any indicators that are only price dependent, not volume, then a simple static variable for 'lastClose' and saved/compared to Close[0] in each OnBarUpdate can save loads of time (if its a cpu heavy indicator). Lots of others can be killed even more just by setting CalculateOnBarClose = true, upping the chart timeframe, dumping tick charts, etcetera.

You should be able to find lots of other tips on futures.io (formerly BMT), but first off I would start using the Task Manager and switching charts on and off to find the real culprits.

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #5 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received


ratfink View Post
E.g. As an example if you have any indicators that are only price dependent, not volume, then a simple static variable for 'lastClose' and saved/compared to Close[0] in each OnBarUpdate can save loads of time (if its a cpu heavy indicator). Lots of others can be killed even more just by setting CalculateOnBarClose = true, upping the chart timeframe, dumping tick charts, etcetera.

Thanks... just wondering, can you show me a snippet of code to demonstrate exactly what you mean by using a static variable like this for Close[0]? I'm still a little unclear on exactly how you implement this...

Reply With Quote
 
  #6 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


FBJS View Post
Thanks... just wondering, can you show me a snippet of code to demonstrate exactly what you mean by using a static variable like this for Close[0]? I'm still a little unclear on exactly how you implement this...

In usual variables region of indicator class:

 
Code
    private double  lastClose;

At start of OnBarUpdate:

 
Code
			// not interested in volume so optimise out same price ticks (lots)
			if (!FirstTickOfBar && Close[0] == lastClose)
				return;
			
			lastClose = Close[0];

So a new bar will always be processed and all new highs/lows are accompanied by changed Close[0]'s as well, so it still sees those.

Have fun! (But do use the TM to identify the greedy ones if you can, and then some will be volume dependent but usually its heavy drawing on lots of redundant price ticks (loads on ES for example)).

edit: Don't really need static in this case, so I'll use private instead. Just normal C#'isms.

Travel Well

Last edited by ratfink; November 21st, 2013 at 03:46 PM.
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #7 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received


ratfink View Post
In usual variables region of indicator class:

 
Code
    private double  lastClose;

At start of OnBarUpdate:

 
Code
			// not interested in volume so optimise out same price ticks (lots)
			if (!FirstTickOfBar && Close[0] == lastClose)
				return;
			
			lastClose = Close[0];

So a new bar will always be processed and all new highs/lows are accompanied by changed Close[0]'s as well, so it still sees those.

Have fun! (But do use the TM to identify the greedy ones if you can, and then some will be volume dependent but usually its heavy drawing on lots of redundant price ticks (loads on ES for example)).

edit: Don't really need static in this case, so I'll use private instead. Just normal C#'isms.

Hey, thanks a lot! Much appreciated...

Reply With Quote
The following user says Thank You to FBJS for this post:
 
  #8 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


FBJS View Post
Hey, thanks a lot! Much appreciated...

You're welcome, another quick change is to go through all your charts and using the 'right-click Properties' menu change all the 'Display update interval's to be longer than the default Ninja 0.5 setting, also make them all different, that way the cpu doesn't always get hit at the same time.

E.g. for my short term charts I use 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, etc, 2.1, 2.2, 2.3 for medium term and 5-15 seconds for longer term charts.

And for working out which are the nasty or badly coded indicators the load-up time on historical charts is probably easier to work from rather than the task manager, but both are well worth the effort.

Travel Well
Reply With Quote
The following 2 users say Thank You to ratfink for this post:
 
  #9 (permalink)
Elite Member
Toronto
 
Futures Experience: Advanced
Platform: NinjaTrader
 
Posts: 108 since Sep 2009
Thanks: 30 given, 183 received


ratfink View Post
You're welcome, another quick change is to go through all your charts and using the 'right-click Properties' menu change all the 'Display update interval's to be longer than the default Ninja 0.5 setting, also make them all different, that way the cpu doesn't always get hit at the same time.

E.g. for my short term charts I use 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, etc, 2.1, 2.2, 2.3 for medium term and 5-15 seconds for longer term charts.

And for working out which are the nasty or badly coded indicators the load-up time on historical charts is probably easier to work from rather than the task manager, but both are well worth the effort.

Thanks again, that's a great idea about alternating the chart intervals to avoid simultaneous CPU hits. Kind of sad that we have to hack around like this to compensate for the platform, hopefully they will do a better job in NT 8 with optimizing performance. Much appreciated!

Reply With Quote
The following user says Thank You to FBJS for this post:

Reply



futures io > > > > > Can this be done? Detect if indicator is running in front-loaded workspace

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
EMA line in front of bars on chart, want to move in front. Help? hector24 NinjaTrader 3 December 12th, 2012 01:28 AM
How to auto restart running indicator? Erez NinjaTrader Programming 13 February 25th, 2012 01:30 PM
Indicator to detect commitment of traders Chipmunk The Elite Circle 18 June 16th, 2011 09:44 AM
Indicator to detect non-trending periods / consolidation? diverdan The Elite Circle 5 May 27th, 2010 06:29 PM
Workspace choices for beginners Gavroche Beginners and Introductions 4 March 28th, 2010 12:19 AM


All times are GMT -4. The time now is 03:03 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-13 in 0.14 seconds with 19 queries on phoenix via your IP 54.163.209.109