Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Bollinger Band Opacity
Collapse
X
-
Hello,
Thanks for your post.
To accomplish this with the Bollinger Bands indicator it may be easiest to right click inside the script of the BB indicator and click "Save As.." This will allow to you to build on top of the existing indicator and make the changes that you would like.
In your new script you would need to set your brush up as you normally would and then assign that brush to your plots. In the case of the Bollinger Bands indicator, you would need to set your custom brush to all three plots.
To set opacity on a brush, you will need to make a new brush, and set the color and opacity you want using the Color.FromArgb() method. The following link is publicly available and goes to the MSDN page for that method.
MSDN- Color.FromArgb()
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
As an example, the code snippet below would set each of the plots that I am adding to my indicator with a custom brush called "myBrush".
If you would like to make opacity a configurable property inside this indicators settings, then you would also need to make sure you add a bit of code similar to the following inside your scripts Property region.Code:protected override void OnStateChange() { if (State == State.SetDefaults) { OpacityValue = 100; AddPlot(Brushes.Goldenrod, "myFirstPlot"); AddPlot(Brushes.Goldenrod, "mySecondPlot"); } } protected override void OnBarUpdate() { if (CurrentBar < 1) return; Brush myBrush = new SolidColorBrush(Color.FromArgb((byte)OpacityValue, 56, 120, 153)); myBrush.Freeze(); PlotBrushes[0][0] = myBrush; PlotBrushes[1][0] = myBrush; }
I am including a link to our help guide documentation for working with custom brushes as well as the PlotBrushes array.Code:[NinjaScriptProperty] [Range(0, int.MaxValue)] [Display(Name="OpacityValue", Description="Opacity value from 0 to 255", Order=1, GroupName="Parameters")] public int OpacityValue { get; set; }
Working with Brushes
https://ninjatrader.com/support/help...th_brushes.htm
PlotBrushes
https://ninjatrader.com/support/help...lotbrushes.htm
Please let me know if you have any further questions.Last edited by NinjaTrader_JoshG; 01-17-2018, 03:43 PM.Josh G.NinjaTrader Customer Service
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
649 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
370 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
574 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
576 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment