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 fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
7 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment