Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Change the background color within script.
Collapse
X
-
When using NinjaScript, you can change the background color
on the main chart panel for the current bar using BackBrush.
To change the background color of all panels, use BackBrushAll.
For previous bars, use BackBrushes or BackBrushesAll.
-
Well, you could just change the background color of each bar,Originally posted by galsermil View PostThis does not tell me how to change all bars.
one at a time, inside OnBarUpdate -- and just keep using the
same color each time -- I mean, just use OnBarUpdate to set
the background to the same color, one bar at time.
Remember, BackBrush and BackBrushAll are continually
updated to refer to the background color of the most recently
closed bar.
Otherwise if you want to change the background of all bars
at once, you have to use your programming skills.
How so? Use the plural variant and set the background color
in a loop, for each bar, like this,
Make sense?Code:for (int indx = 0; indx < CurrentBar; ++indx) BackBrushes[indx] = Brushes.LightSkyBlue;
Comment
-
Then a solution could be to process just those bars that are visible on screen, but then, if you scroll back, previous bars would not have that color.Originally posted by galsermil View PostThis is my second attempt at solving this mystery. When I first advised of this this loop solution, my script merely skipped over it but I was not surprised as my CurrentBar was 15641. That is a lot of bars to process.
Tip#2: if you choose OnBarUpdate solution, make sure, you are not using it within backtest/optimization, as it's fully redundant to render any colors and it would eat up lots of space.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment