Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator code placement
Collapse
X
-
Hello JTizz,
Thank you for your post.
I have moved this thread to Indicator Developement.
Where you use BarBrush in your code would depend on what you are trying to accomplish. If you would like to change the BarBrush color when a certain condition happens, you would need to create that condition followed by calling BarBrush.
See the attached example script which demonstrates using BarBrush to change the color of a bar when a certain condition happens.
Also, see this help guide link for more information.
BarBrush - https://ninjatrader.com/support/help...8/barbrush.htm
Let us know if we may assist further.
Attached Files<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hello JTizz,
Our role is not really to advise on "copy this code and paste it here" so much as it is to support our product and provide direction for accomplishing your tasks.
Changing the BarBrush property will require that you understand how the BarBrush property can be used and a will also involve basic understanding of C# syntax. You will need to know what exactly you will want to check to create your condition to then set BarBrush.
Basic Programming Concepts - https://ninjatrader.com/support/help...g_concepts.htm
Please observe that in the strategy code, the indicator plots are referenced as DynamicSR.Resistance[0] and DynamicSR.Support[0]. Within the indicator, you would not reference those plots as DynamicSR.Resistance[0] and DynamicSR.Support[0], because you are already in the indicator. You could just reference Support[0] and Resistance[0] after they have been set.
We look forward to assisting.
Comment
-
Hello JTizz,
Thank you for your note.
If you are wanting to create a modified version of the DynamicSR indicator, you could download and import the DynamicSR indicator followed by modifying the indicator in a New > NinjaScript Editor window. To do so, you would open a New > NinjaScript Editor window, double-click the Indicators folder, then select the DynamicSR indicator. Right-click in the indicator's code and click 'Save as' to create a copy of the DynamicSR indicator.
After creating a copy of the DynamicSR indicator, you would create conditions in your script that check if the current Close[0] is greater than or less than the Support[0]/Resistance[0] plot and call BarBrush to change the color of a bar when that condition becomes true.
Let us know if we may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hello JTizz,
Thank you for your note.
As stated by my colleague Jim, our role is not really to advise on "copy this code and paste it here" so much as it is to support our product and provide direction for accomplishing your tasks.
Changing the BarBrush property will require that you understand how the BarBrush property could be used and will also involve a basic understanding of C# syntax. You will need to know what exactly you will want to check to create your condition to then set BarBrush.
Basic Programming Concepts - https://ninjatrader.com/support/help...g_concepts.htm
That being said, you would create your conditions in the OnBarUpdate() method of the script. Something you could do is check if the current Close[0] is greater than the Resistance[0] plot and call BarBrush to change the color of the bar to blue. The code would look something like this.
This would also need to be done for the Support[0] plot to change the bar color to magenta when the current Close[0] is less than the Support[0] plot.Code:protected override void OnBarUpdate() { if (Close[0] > Resistance[0]) BarBrush = Brushes.Blue; }
Let us know if we may assist further.
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hello JTizz,
I would suggest starting with a simple indicator that changes BarBrush to get acquainted using this property.
For example, you can start with the following in a new indicator.
After you are familiar using that code implement it in the custom indicator you want to modify and make sure it still sets the bar color.Code:protected override void OnBarUpdate() { if (Close[0] > Open[0]) BarBrush = Brushes.Orange; else if (Close[0] < Open[0]) BarBrush = Brushes.Purple; }
Then, instead of checking Open vs. Close, use the Support and Resistance Series and compare that with the close price of the bar.
Debugging prints may be used to print out the values used in the conditions so you may see why the condition is/is not becoming true and allowing BarBrush to bet set. The prints may be viewed in a NinjaScript Output Window.
Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
599 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
344 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
557 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment