private void sizeBox_TextChanged(object s, EventArgs e){ TextBox b = (TextBox) s; showSize = Convert.ToInt32(b.Text); ForceRefresh(); }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
ForceRefresh() not refreshing chart
Collapse
X
-
ForceRefresh() not refreshing chart
I'm using the code to change the value of a textbox in the MainMenu of a chart. The function is called correctly and showSize is updated, however ForceRefresh does not repaint the chart. I have to click and drag the chart for any updates to be rendered. Is there another function that calls OnRender()?
Code:Last edited by habibalex; 10-26-2015, 05:20 PM.Tags: None
-
ForceRefresh() queues OnRender() to be called by resetting an internal marker which is used to determine when OnRender() should be called next. It does not immediately invalidate the chart control and is documented as a "safe" way to update the chart should you need to (e.g., there has not be a recent tick).
For more advanced programming such as adding and interacting with 3rd party controls, you should consider use ChartControl.InvalidateVisual().
This is an "unsafe" and undocumented method which can lead to performance or threading issues. Only programmers experienced with threading and understand the impact of excessive calls to OnRender() should use this method.
I've attached a test indicator to demonstrate the difference.
To test:
• Add this indicator to a chart which will add two buttons to the Chart's Main Menu
• Disconnect from any data feeds (to prevent additional calls to OnRender which may obscure your test)
• Open the NinjaScript output window.
• Click on either button to observe the difference.
The result should print the time span from OnRender() was last called.
As you will observe, ForceRefesh() will end up in calling OnRender(), however on some subsequent clicks, you'll notice that ForceRefresh() does not always trigger an OnRender() for each time it is called, e.g.,
ForceRefresh() Clicked
Seconds since last render=0.1750175
ForceRefresh() Clicked
Seconds since last render=0.8130813
ForceRefresh() Clicked
ForceRefresh() Clicked
ForceRefresh() Clicked
Seconds since last render=1.0731073
ForceRefresh() Clicked
ForceRefresh() Clicked
Seconds since last render=0.4890489
InvalidateVisual() Clicked
Seconds since last render=0.1750175
InvalidateVisual() Clicked
Seconds since last render=0.1350135
InvalidateVisual() Clicked
Seconds since last render=0.1610161
InvalidateVisual() Clicked
Seconds since last render=0.1720172
InvalidateVisual() Clicked
Seconds since last render=0.1430143
InvalidateVisual() Clicked
Seconds since last render=0.1510151Attached FilesMatthewNinjaTrader Product Management
-
Originally posted by habibalex View PostAlso, when trying to change the value of my textbox by entering numbers, ninjatrader will bring up the quick time period change dialog. I'm getting around the issue by using my middle mouse wheel to scroll, but eventually this should be fixed as well.
MatthewNinjaTrader Product Management
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by proptradingshop, 03-21-2024, 09:50 AM
|
5 responses
26 views
0 likes
|
Last Post Today, 05:17 AM | ||
Started by MaupinFinche, Today, 05:08 AM
|
0 responses
2 views
0 likes
|
Last Post
by MaupinFinche
Today, 05:08 AM
|
||
Started by Enkidu, Yesterday, 06:40 AM
|
9 responses
35 views
0 likes
|
Last Post
by Enkidu
Yesterday, 01:11 PM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
12 responses
307 views
0 likes
|
Last Post
by z.franck
Today, 04:29 AM
|
||
Started by AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
268 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
Comment