If the plot color is updated via the indicator property UI, is there a recommended way of changing the plotbrush?
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
detecting property changes
Collapse
X
-
Hello fingers,
Thank you for your post.
If the plot color is updated, the brush color should be automatically updated for the indicator unless you have logic that changes PlotBrushes. If that is the case, you could consider adding user-definable color inputs to your script as explained on this page and in the SampleBrushInput script:
If you do not wish for the user to be able to change a plot's configuration on the UI, you could set ArePlotsConfigurable to false:
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
-
Hello fingers,
Thank you for your reply.
If the default color is set to Brushes.Red, that just means that Red will be the color selected in the dropdown menu by default when you select the indicator to add it to a chart. Nothing must be done to change the color of the plot if the property changes as it will already pull the value of whatever color is selected from the dropdown menu. Using the EMA indicator as an example, it calls AddPlot() as follows in State.SetDefaults:
Code:AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA);
If you change the color from Goldenrod to something else, the plot for the EMA will automatically pull the color value that is selected without having to specify that color anywhere else in the script for EMA:
You should be able to test this in your indicatory by changing the plot color in the indicator settings, then clicking Apply to see the change after it is applied. Unless you are programmatically changing the plot color to something else, the color change should apply to the plot without needing to add other logic.
Please let us know if we may be of further assistance.Emily C.NinjaTrader Customer Service
- Likes 1
Comment
-
ok yes, fixed now, thanks. This is what I'm trying to do:
Code:if (State == State.SetDefaults) { longTrade = true; if (longTrade) { AddPlot(Brushes.RoyalBlue, "plotLong1"); AddPlot(Brushes.Blue, "plotLong2"); } else { AddPlot(Brushes.LightCoral, "plotShort1"); AddPlot(Brushes.Red, "plotShort2"); } }
Last edited by fingers; 11-04-2023, 05:22 AM.
Comment
-
Hello fingers,
Thank you for your reply.
I see you are trying to add plots dynamically. This should be done in State.Configure and not in State.SetDefaults. There is an example of adding plots dynamically in State.Configure at the bottom of the page here:
Additionally, the note at the top of the page is relevant for this use case as well:
Note: Plots are ONLY visible from the UI property grid when AddPlot() is called from State.SetDefaults. If your indicator or strategy dynamically adds plots during State.Configure, you will NOT have an opportunity to select the plot or to set the plot configuration via the UI. Alternatively, you may use custom public Brush, Stroke, or PlotStyle properties which are accessible in State.SetDefaults and pass those values to AddPlot() during State.Configure. Calling AddPlot() in this manner should be reserved for special cases. Please see the examples below.Emily C.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,403 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
94 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
6 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 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