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
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 FilesBrandon H.NinjaTrader Customer Service
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.JimNinjaTrader Customer Service
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.Brandon H.NinjaTrader Customer Service
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.
Code:protected override void OnBarUpdate() { if (Close[0] > Resistance[0]) BarBrush = Brushes.Blue; }
Let us know if we may assist further.
Brandon H.NinjaTrader Customer Service
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.
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.htmJimNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Padan, Today, 02:02 AM
|
3 responses
11 views
0 likes
|
Last Post Today, 08:54 AM | ||
Started by Tim-c, Today, 08:36 AM
|
1 response
3 views
0 likes
|
Last Post Today, 08:45 AM | ||
Started by goodknight777, Today, 08:43 AM
|
0 responses
2 views
0 likes
|
Last Post Today, 08:43 AM | ||
Started by martini, Yesterday, 04:45 PM
|
3 responses
28 views
0 likes
|
Last Post Today, 08:38 AM | ||
Started by Mestor, Today, 03:15 AM
|
2 responses
10 views
0 likes
|
Last Post
by Mestor
Today, 08:36 AM
|
Comment