Can you provide a link or sample to help accomplish that?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Change Swing Plot Colors Based On Condition
Collapse
X
-
Change Swing Plot Colors Based On Condition
I want to modify the Swing indicator so that the plot colors are set based on a condition.
Can you provide a link or sample to help accomplish that?Tags: None
-
Hello ScorpioTravis,
Thank you for the post.
The swing can be duplicated and then edited by using the NinjaScript editor. To duplicate the file you would first need to open it and then right click in the file -> Save as.
The swing is a fairly complicated indicator which can be pretty difficult to edit. We would likely need more specific details on what kind of conditions you are looking to make in order to provide more relevant help here.
To color plots you can use PlotBrushes https://ninjatrader.com/support/help...ub=PlotBrushes
I look forward to being of further assistance.
-
Jesse, I made a copy and modified it by adding the following lines at the end of the protected override void OnBarUpdate() section (CONDITION# = other indicator values):
It seems to work as expected, however, there are some yellow plots even though CONDITION1 and CONDITION2 are both false.Code:{ if (CONDITION1 && CONDITION2) { PlotColors[0][0] = Color.Transparent; PlotColors[1][0] = Color.Yellow; } else if (CONDITION3 && CONDITION4) { PlotColors[0][0] = Color.Cyan; PlotColors[1][0] = Color.Transparent; } else { PlotColors[0][0] = Color.Transparent; PlotColors[1][0] = Color.Transparent; } }
I can't determine if that's caused by something in the original SWING code or if it's because of an error I made in the additional code logic for changing the colors.
Update: I sent the indicator data used for the CONDITION#s to an output window, but it doesn't match what's on the chart and data box. I'm still investigating.
Last edited by ScorpioTravis; 10-05-2021, 06:00 PM.
Comment
-
Hello ScorpioTravis,
When you say that you sent the indicator data are you referring to the plot data from the indicator or are you using SwingLowBar/HighBar?
For your conditions you would need to use a print to see what the values are on each bar where the conditions are both false.
I look forward to being of further assistance.
Comment
-
Yes, I used PRINT to confirm that for some reason I have yet to determine, the CONDITION#s are both true even though on the chart they're both false.Originally posted by NinjaTrader_Jesse View PostHello ScorpioTravis,
When you say that you sent the indicator data are you referring to the plot data from the indicator or are you using SwingLowBar/HighBar?
For your conditions you would need to use a print to see what the values are on each bar where the conditions are both false.
I look forward to being of further assistance.
Comment
-
I don't think I can sufficiently explain it without sending the indicators to you, and I don't expect you to review them.Originally posted by NinjaTrader_Jesse View PostHello ScorpioTravis,
Could you provide more details about the condition? Are you using indicator values and comparing against manually added indicators? That could be a situation where the chart may differ from the script.
I look forward to being of further assistance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment