Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
MACD UpDown
Collapse
X
-
Use the PlotColors Method
Hi, the Magic you want is in the PlotColors API. Below is a sample of some code you may try.
As you may see from the font, I've edited some code I use for something else & haven't tested it specifically for your use here.
eg: Using Ticksize makes more sense for MA's & those plotted in the Price chart. For oscillators you'll probably need to adjust to suit.
Hope this points you in the right direction.Code:private double FLAT_TOLERANCE; [FONT=Calibri]FLAT_TOLERANCE = 0.05 * TickSize; // 5% of a Tick[/FONT] [FONT=Calibri]if ( Math.Abs([FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MACD(Close,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]][/SIZE][/FONT][/SIZE][/FONT] - [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MACD(Close,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]][/SIZE][/FONT][/SIZE][/FONT]) <= FLAT_TOLERANCE) { //Flat[/FONT] [FONT=Calibri] PlotColors[0][0] = colorFlat;[/FONT] [FONT=Calibri]}[/FONT] [FONT=Calibri]else if ( ([FONT=Courier New][SIZE=2]Close,[COLOR=#800080][COLOR=#800080][COLOR=#800080]12[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]26[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]9[/COLOR][/COLOR][/COLOR])[[COLOR=#800080][COLOR=#800080][COLOR=#800080]1[/COLOR][/COLOR][/COLOR]][/SIZE][/FONT] - [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MACD(Close,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]][/SIZE][/FONT][/SIZE][/FONT]) >= FLAT_TOLERANCE ) { //Down[/FONT] [FONT=Calibri] PlotColors[0][0] = colorDown;[/FONT] [FONT=Calibri]}[/FONT] [FONT=Calibri]else if (([FONT=Courier New][SIZE=2]Close,[COLOR=#800080][COLOR=#800080][COLOR=#800080]12[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]26[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]9[/COLOR][/COLOR][/COLOR])[[COLOR=#800080][COLOR=#800080][COLOR=#800080]0[/COLOR][/COLOR][/COLOR]][/SIZE][/FONT] - [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]MACD(Close,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]12[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]26[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]9[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]][/SIZE][/FONT][/SIZE][/FONT]) >= FLAT_TOLERANCE ) { //Up[/FONT] [FONT=Calibri] PlotColors[0][0] = colorUp;[/FONT] [FONT=Calibri]}[/FONT] [FONT=Calibri]Plot0.Set([FONT=Courier New][SIZE=2]MACD(Close,[COLOR=#800080][COLOR=#800080][COLOR=#800080]12[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]26[/COLOR][/COLOR][/COLOR],[COLOR=#800080][COLOR=#800080][COLOR=#800080]9[/COLOR][/COLOR][/COLOR])[[COLOR=#800080][COLOR=#800080][COLOR=#800080]0[/COLOR][/COLOR][/COLOR]][/SIZE][/FONT]);[/FONT]
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
602 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 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
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
559 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment