Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Change current bar color of a custom bar type
Collapse
X
-
Change current bar color of a custom bar type
I am using a custom bar type where I do not have access to the code. I would like the current bar painted not green or red as it is painted by the proprietary bar type, but in another color. Is there a way to "overlay" the bar color with another one on the chart?Tags: None
-
Hello chris07,
Thanks for your post.
Yes, with a custom script you can color the bars as you wish.
Please see the following methods that would allow you to color the bar and/or the outline of the candle
https://ninjatrader.com/support/help...l?barbrush.htm
https://ninjatrader.com/support/help...barbrushes.htm
https://ninjatrader.com/support/help...tlinebrush.htm
https://ninjatrader.com/support/help...inebrushes.htmPaul H.NinjaTrader Customer Service
-
Paul,
thank you for the pointers! I have created a new indicator, but this changes the color of all previous candles, but not the current one:
// Sets the color of the current bar to transparent.
BarBrushes[0] = Brushes.Transparent;
the same thing happens when I use the sample code from the tutorial:
if (CurrentBar < 0)
return;
// Sets the color of the current bar to transparent.
BarBrushes[0] = Brushes.Transparent;
Attached FilesLast edited by chris07; 12-07-2021, 01:18 PM.
Comment
-
Hello chris07,
Thanks for your reply.
If you are running the indicator with calculate.OnBarClose then [0] will be the current bar and the currently forming bar will not be known until it closes at which point your code will color that bar.
If you want to color the currently forming bar then you will need to change the script calculate setting to Calculate.OnPriceChange or Calculate.OnEachTick.
this code: if (CurrentBar > 0) return; Will not work because as soon as the 2nd historical bar is loaded to return. Return means don't do anything, so if the bar counter "CurrentBar" is greater than 0 (0 is the first bar of the data series) to then return and no further code is executed.
Paul H.NinjaTrader Customer Service
- Likes 1
Comment
-
Hi Paul,
thank you for the explanations. I have set
Calculate = Calculate.OnEachTick;
however, now all the bars have their color changed.Attached Files
Comment
-
The intention is to have the background color as bar color for the current bar. I could use white instead, but my background is set to an off white color. So I thought it would be more conventient to use transparent in case I change the background color.Last edited by chris07; 12-07-2021, 02:10 PM.
Comment
-
Hello chris07,
Thanks for your reply.
I am probably misunderstanding what your goal is but here is what I see with your script, all bars transparent and just the outline remains.
If that is not what you are after, please elaborate on what you are wanting to see and/or post a screenshot that illustrates.
Paul H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by alifarahani, Today, 09:40 AM
|
6 responses
31 views
0 likes
|
Last Post
by alifarahani
Today, 03:18 PM
|
||
Started by Waxavi, Today, 02:10 AM
|
1 response
17 views
0 likes
|
Last Post Today, 03:03 PM | ||
Started by Kaledus, Today, 01:29 PM
|
5 responses
13 views
0 likes
|
Last Post Today, 02:56 PM | ||
Started by Waxavi, Today, 02:00 AM
|
1 response
12 views
0 likes
|
Last Post Today, 02:53 PM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
3 responses
17 views
0 likes
|
Last Post Today, 02:41 PM |
Comment