![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Charting Support for NinjaTrader Advanced Charting. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jan 2012
Posts: 73
Thanks: 19
Thanked 1 time in 1 post
|
I have a very specific question that I think the developers may be able to answer.
Imagine that you have 3 indicators on a particular chart, called A, B, and C. Indicators A and B are set to CalcOnBarClose=True, and Indicator C is set to CalcOnBarClose=False, which means it updates on every tick. When a new tick comes in, obviously the OnBarUpdate call will execute on Indicator C, which I would think would also trigger the Plot method of that same indicator, to be able to visually show the new value on the chart. The question is, does executing the Plot method of Indicator C also indirectly trigger the Plot methods of indicators A and B? If the whole window is repainting as a result of a change in C, I would think that A and B also need to be repainted. This scenario means that if there is CPU-intensive code in the Plot routines of A and B, it will still get triggered on every tick, even though CalcOnBarClose is set to True for those indicators. Is this the case, or am I missing something? Thanks! |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Trader,
In this case, there would be no calling of the other indicators methods like OnBarUpdate except for whatever is internally done for the graphics code. Plot methods wouldn't be accessible to you in supported code, and typically they do not need to be changed.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_AdamP for this post: |
|
|
|
#3 | |
|
Member
Join Date: Jan 2012
Posts: 73
Thanks: 19
Thanked 1 time in 1 post
|
Quote:
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) There is an indicator in the support forum indicators section called dValueArea7 which does this, along with a number of others. So I know that the OnBarUpdate call of the other indicators is not triggered, but is the Plot method triggered? Sometimes there is quite a bit of code in there, which can be even more intensive than what is in the OnBarUpdate call... |
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Trader,
Yes, the plot method can be overridden as its part of the inheritance of the Indicator class. Its just that we don't have a reference sample on doing this currently, nor do we cover it in the help guide. This basically means "unsupported" but not "impossible". I am actually not sure here when the plot method would be called in relation to OnBarUpdate(), I suspect it would be after but I am not positive in the scenario you mentioned. I'll check with some other members of our NS team on Monday to see if they have any idea and get back to you.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_AdamP for this post: |
|
|
|
#5 | |
|
Member
Join Date: Jan 2012
Posts: 73
Thanks: 19
Thanked 1 time in 1 post
|
Quote:
|
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
|
Trader,
After talking with my colleagues, it looks like Plot() is called after each OnBarUpdate() and is responsible for drawing that indicator on the chart. Unfortunately this is a "under the hood" method, and though it can be overridden, it is not recommended. We removed this after NT 6.5 due to some unexpected behavior when people override it, or used it improperly. Unfortunately I can't really comment much further on this, apologies for any inconvenience.
Adam P.
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Oct 2007
Posts: 1,829
Thanks: 12
Thanked 83 times in 67 posts
|
Just two remarks:
There is a number of NinjaTrader system indicators which override the plot method. This includes the Pivots, RegressionChannel, VolumeProfile, VolumeZones, ZigZag. You can use them as a reference. The plot is not updated each time OnBarUpdate() has been called. In a fast market you will only get an update after the display update interval, which I have set to 0.5 seconds for my purposes. If you use a display update interval, which is too small, NinjaTrader may freeze in a fast market depending on what is done in the custom plots. |
|
|
|
|
The following user says thank you to Harry for this post: |
|
|
|
#8 | |
|
Member
Join Date: Jan 2012
Posts: 73
Thanks: 19
Thanked 1 time in 1 post
|
Quote:
|
|
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Oct 2007
Posts: 1,829
Thanks: 12
Thanked 83 times in 67 posts
|
Quote:
When the chart is refreshed all indicators are plotted, as far as I know this does not depend on whether CalculateOnBarClose has been set to true or false. The chart is refreshed earliest when the display update interval has elapsed and a new tick was registered during that interval or afterwards. As far as I have understood this means that the code of the Plot Override() method may be executed every 0.5 seconds, if the display update interval for the chart is set to that value. This would apply to indicators with both CalculateOnBarClose set to true or false. For the CPU load this would mean -> CalculateOnBarClose = true -> OnBarUpdate() is triggered once at the bar close -> CalculateOnBarClose = false -> OnBarUpdate() is triggered with every incoming tick -> display update interval = 100 msec -> code contained within Plot Override() is executed up to 10 times per second for all indicators, depending on incoming ticks But again, it would be better to have this explanation confirmed by somebody else. |
|
|
|
|
|
|
#10 | |
|
Member
Join Date: Jan 2012
Posts: 73
Thanks: 19
Thanked 1 time in 1 post
|
Quote:
|
|
|
|
|
|
|
#11 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Thanks for your help here Harry.
There are internal mechanisms for plotting the currently forming price bar, outside of any script that is applied. OnBarUpdate() drives chart plotting for indicators and frequency of calls are raised according to CalculateOnBarClose setting defined for the indicator. It's either every tick (false) or on bar close(true). While OnBarUpdate() will drive plot charting, the chart display is updated only as often as the refresh setting you define in properties. This doesn't affect calculations. It's the smallest time in-between chart display updates. Unless you are overriding plot you still need ticks (OBU calls) as the main driver for indicator plotting. If you override plot, then you could manually control when your chart is drawn, through custom events like timers.
Ryan M
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CPU Usage still too high | Sergio66 | Version 7 Beta General Questions & Bug Reports | 12 | 10-25-2010 03:04 PM |
| CPU Usage | hegh2000 | Version 7 Beta General Questions & Bug Reports | 8 | 07-01-2010 03:17 PM |
| CPU Usage | Alfred | Miscellaneous Support | 10 | 03-10-2009 04:52 AM |
| cpu usage | ckait | Miscellaneous Support | 18 | 11-12-2008 02:19 AM |
| CPU usage | magicboiz | Connecting | 1 | 10-15-2008 07:35 AM |