If the plot color is updated via the indicator property UI, is there a recommended way of changing the plotbrush?
Announcement
Collapse
No announcement yet.
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.
-
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:
This just means that when you select the EMA to add it to a chart, the default color selected for the plot is Goldenrod:Code:AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameEMA);
World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
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:
World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
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.
- Likes 1
Comment
-
ok yes, fixed now, thanks. This is what I'm trying to do:
but if I change longTrade = false, I still get plotLong?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:
Please let us know if we may be of further assistance.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.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
597 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
343 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
556 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
555 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment