Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Serializing Indicator
Collapse
X
-
Curious Plots
The following code is not plotting dots as I would like.
It is supposed to plot a dot when the FATL line crosses above the SATL line.
FATL and SATL are DataSeries from added Plots in the Initialize section.
Add(new Plot(Color.Gray, PlotStyle.Line, "FATL")); Values[0] plots the line
Add(new Plot(Color.Gray, PlotStyle.Line, "SATL")); Values[2]
Add(new Plot(Color.Gray, PlotStyle.Dot, "FATLDots"));Values[4] plots dots on the line
FATL and FATLDots are SET to the same values.
if (CrossAbove(FATL,SATL,1)== true)
{
Plots[4].Pen.Color = crossUpColor;
Plots[4].Pen.Width = fatColorWidth;
} else Plots[4].Pen.Color = Color.Transparent;
Print(Time[0].ToString()+" FATL="+ FATL[0]+" SATL="+SATL);
Print(Time[0].ToString()+" If FAT Xover SAT, bool="+CrossAbove(FATL,SATL,1));
The Print statements verify that the 'if' statement is giving correct T and F readings,
However, when the code is as shown above, NO dots print (ie thay are all transparent).
If I "// out" the else statement with
} // else Plots[4].Pen.Color = Color.Transparent;
then dots appear on EVERY bar.
I must be missing something . Is there an easy fix?
Comment
-
Thanks,
I rewrote it using
PlotColors[4][0] = Color.FromArgb(defaultColorOpacity,crossUpColor);
because I serialized my colors.
Since I borrowed that piece of code, I'm not sure if I have to put in Opacity for a
Serialized color or if that was just something that the other developer needed.
Can anyone tell me?
Comment
-
I'm getting "Indicator could not be serialized", and there are user defined colors in the indicator. I would love to view the thread linked above! Alas, the link appears to be broken. Please advise.Originally posted by NinjaTrader_RyanM View PostHello DaveN,
The most common property to serialize is user defined color inputs. Details on serializing color inputs are here:
If you can share the properties region of your code we can tell if it's a different property causing this.
Thanks!
Comment
-
If you search the forum for the phrase: "serialize color", you should eventually come upon this thread: http://www.ninjatrader.com/support/f...ead.php?t=4977Originally posted by Style View PostI'm getting "Indicator could not be serialized", and there are user defined colors in the indicator. I would love to view the thread linked above! Alas, the link appears to be broken. Please advise.
Thanks!
Comment
-
Thanks! I went through that thread and did what it said, but I'm still getting the error. I'm attaching the code. Any ideas what I'm doing wrong? Thanks again!Originally posted by koganam View PostIf you search the forum for the phrase: "serialize color", you should eventually come upon this thread: http://www.ninjatrader.com/support/f...ead.php?t=4977
Attached Files
Comment
-
I believe I'm now using [XmlIgnore()] correctly, yet the issue remains. See the attached code.Originally posted by NinjaTrader_Bertrand View PostStyle, do you have the [XmlIgnore()] for your Color properties added as well, to signify you do custom serialization for those?
I'm not sure what you mean.Originally posted by NinjaTrader_Bertrand View PostI also believe your public struct will need custom serialization...
Thanks for your help!Attached Files
Comment
-
Not to contradict Bertrand, but your struct, while declared public, is not a Property of the class, so is unlikely to be causing a problem with the NT wrappers. I use structs pretty liberally myself, declared either as public or protected and have no issue there, unless I try to use the struct as a property, which causes a different issue actually.Originally posted by Style View PostI believe I'm now using [XmlIgnore()] correctly, yet the issue remains. See the attached code.
I'm not sure what you mean.
Thanks for your help!
It seems that the problem may be in your declaration of your DataSeries as public. If you want to access DataSeries outside of the class, you should define the access using a Property referring to a private backing store, not declare the DataSeries as public access in the code.Last edited by koganam; 07-20-2012, 06:29 AM. Reason: Corrected language to use proper programming lingo
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
606 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
353 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment