The problem is that it always draws the most recent bars corona on all past bars. I have tried several different methods of drawing it with no success so I figured I would post the code here and see if anyone with more custom drawing experience can figure it out.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GDI problem - Ehlers Corona Indicators
Collapse
X
-
GDI problem - Ehlers Corona Indicators
I am trying to port Ehlers Corona Indicators to NT, have them very near complete but I cannot get the coronas to draw properly.
The problem is that it always draws the most recent bars corona on all past bars. I have tried several different methods of drawing it with no success so I figured I would post the code here and see if anyone with more custom drawing experience can figure it out.Tags: None
-
here is the relevant drawing code from plot override.
this is what it looks like, as you can see the corona changes properly but it paints the same corona across the entire chart rather than leaving the past values. I have used very similar drawing code before to draw lines, etc and it worked fine but in this case I have tried several methods with no luck. Perhaps NT handles drawing the background differently?Code:int bars = ChartControl.BarsPainted, index; bars = CalculateOnBarClose ? (ChartControl.BarsPainted - 2) : (ChartControl.BarsPainted - 1); double x1, y1, y2; double vscale = bounds.Height / ChartControl.MaxMinusMin(max, min); Exception caughtException; while (bars >= 0) { //index = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + bars; index = ((ChartControl.LastBarPainted - ChartControl.BarsPainted) - 1) + bars; if (ChartControl.ShowBarsRequired || ((index - base.Displacement) >= base.BarsRequired)) { try { x1 = // horizontal position of bar to plot (((ChartControl.CanvasRight - ChartControl.BarMarginRight) - (barPaintWidth / 2)) - ((base.ChartControl.BarsPainted - 1) * base.ChartControl.BarSpace)) + (bars * (base.ChartControl.BarSpace)); for (int i = 11; i < 60; ++i) { double v = (i+1)/2; y1 = (bounds.Y + bounds.Height) - (int)((v + 1.5 - min) * vscale + 0.5); y2 = (bounds.Y + bounds.Height) - (int)((v - min) * vscale + 0.5); SolidBrush brush = new SolidBrush(_colors[(int) Math.Round(_filters[index-1][i].dB[0])]); graphics.FillRectangle(brush, new Rectangle((int)x1 - barPaintWidth / 2, (int)y2, barPaintWidth, (int)Math.Abs(y1 - y2))); } } catch (Exception exception) { caughtException = exception; } } bars--; } graphics.SmoothingMode = smoothingMode;

Comment
-
No there is 48 horizontal colored lines per bar, they are plotting correctly.
The issue is that once the bar changes, all past bars on the chart show the 48 colors assigned to the CurrentBar, rather than the colors that go with that bar.
I have tried adding 48 plot objects which all contain horizontal lines and coloring them in the plot method but couldn't get that to work either, and it is much more resource intensive than using graphics.FillRectangle() so it wouldn't be a good solution anyways.
On this pdf you can see how it is supposed to look:
Comment
-
sefstrat, did you already take at look at this from the sharing section? http://www.ninjatrader-support2.com/...endline&desc=1
Comment
-
Tomas, sorry the code is somewhat convoluted because I have been experimenting with different drawing techniques but I am pretty certain it is correct.
Bertrand, yes I have seen TLFit and consulted it while writing this drawing code. Unfortunately however, TLFit does not draw properly on my computer either (it has the exact same problem, all bars show the fit of currentbar).
That is one thing I find confusing since obviously TLFit worked before (based on the screenshot from when it was posted), has there been any changes to NT drawing code since then that would affect this?
Can you try TLfit on your machine and see if it works properly?
Comment
-
Hi sefstrat,
it seems that i was right. The problem appeared during clonning. When changing line
_filters[CurrentBar] = (FilterBank[])_filters[CurrentBar - 1].Clone();
to
FilterBank[] b = new FilterBank[60];
for (int n = 11; n < 60; n++)
b[n] = (FilterBank)_filters[CurrentBar - 1][n].Clone();
_filters[CurrentBar] = b;
it starts to work as expected.
Tomas
Comment
-

Thanks Tomas, you are the man.
I implemented ICloneable to make it easier to debug the drawing code, apparently that didn't work out so well.
The fact that TLFit was doing the same thing made me a little too certain the problem wasn't with my code, still not sure why TLFit doesn't work for me but no matter.
Later this afternoon I will finish the rest of the corona indicators and post them here. =)
(And yes I will use the correct line color in the final product eDanny
)
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment