How do i correctly update PlotBrushes? Samples indicate that i can just set them in OnbarUpdate, however this does not always work. For example, if i use my indicator as an input to another indicator then i get "Indicator 'MyIndicator': Error on calling 'OnBarUpdate' method on bar 0: The calling thread cannot access this object because a different thread owns it." error. Using Dispatcher.Invoke makes things very slow. Using Dispatcher.InvokeAsync seems to apply color to the wrong bar, no matter how i try to do it (probably my mistake, but still it is not clear how to do it correctly).
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Updating PlotBrushes
Collapse
X
-
Updating PlotBrushes
Hi,
How do i correctly update PlotBrushes? Samples indicate that i can just set them in OnbarUpdate, however this does not always work. For example, if i use my indicator as an input to another indicator then i get "Indicator 'MyIndicator': Error on calling 'OnBarUpdate' method on bar 0: The calling thread cannot access this object because a different thread owns it." error. Using Dispatcher.Invoke makes things very slow. Using Dispatcher.InvokeAsync seems to apply color to the wrong bar, no matter how i try to do it (probably my mistake, but still it is not clear how to do it correctly).Last edited by rokups; 11-01-2024, 06:03 AM. -
I modified MACD indicator to display a colored histogram. See attached file.Attached Files
Comment
-
Hello rokups,
You need to freeze the brushes you are making. You can read about using brushes in the link below, from that link:Warning: If you do not call .Freeze() on a custom defined brush WILL eventually result in threading errors should you try to modify or access that brush after it is defined. Note: Anytime you create a custom brush that will be used by NinjaTrader rendering it must be frozen using the .Freeze() method due to the multi-threaded nature of NinjaTrader.
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
52 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
71 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
38 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
99 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
60 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment