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
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".
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; }
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 AgriTrdr, 07-16-2023, 12:54 PM
|
32 responses
266 views
0 likes
|
Last Post
by f.saeidi
Yesterday, 06:49 AM
|
||
Started by Mestor, Today, 03:15 AM
|
0 responses
1 view
0 likes
|
Last Post
by Mestor
Today, 03:15 AM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
11 responses
305 views
0 likes
|
Last Post
by z.franck
Today, 02:29 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
409 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
Comment