NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-08-2012, 06:34 PM   #16
magnumdbl
Junior Member
 
Join Date: Sep 2011
Location: New Jersery
Posts: 9
Thanks: 2
Thanked 0 times in 0 posts
Send a message via Skype™ to magnumdbl
Default

That WORKED and now it saves in Templates.
magnumdbl is offline  
Reply With Quote
Old 04-10-2012, 12:21 AM   #17
magnumdbl
Junior Member
 
Join Date: Sep 2011
Location: New Jersery
Posts: 9
Thanks: 2
Thanked 0 times in 0 posts
Send a message via Skype™ to magnumdbl
Default 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?
magnumdbl is offline  
Reply With Quote
Old 04-10-2012, 06:23 AM   #18
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

magnumdbl, for changing plot colors dynamically, please use NT7's PlotColors method in your code -

http://www.ninjatrader.com/support/h...plotcolors.htm
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 04-10-2012, 11:01 PM   #19
magnumdbl
Junior Member
 
Join Date: Sep 2011
Location: New Jersery
Posts: 9
Thanks: 2
Thanked 0 times in 0 posts
Send a message via Skype™ to magnumdbl
Default

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?
magnumdbl is offline  
Reply With Quote
Old 04-11-2012, 02:37 AM   #20
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

Believe you would need that here, as the opacity is a component of the from ARGB derived color you create for your script.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-26-2012, 06:04 PM   #21
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by NinjaTrader_RyanM View Post
Hello DaveN,

The most common property to serialize is user defined color inputs. Details on serializing color inputs are here:
http://www.ninjatrader-support.com/v...ead.php?t=4977

If you can share the properties region of your code we can tell if it's a different property causing this.
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.

Thanks!
Style is offline  
Reply With Quote
Old 06-26-2012, 06:15 PM   #22
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by Style View Post
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.

Thanks!
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=4977
koganam is offline  
Reply With Quote
The following 2 users say thank you to koganam for this post:
Old 06-27-2012, 06:14 PM   #23
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by koganam View Post
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=4977
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!
Attached Files
File Type: zip dots.zip (3.5 KB, 5 views)
Style is offline  
Reply With Quote
Old 06-28-2012, 02:27 AM   #24
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

Style, do you have the [XmlIgnore()] for your Color properties added as well, to signify you do custom serialization for those?

I also believe your public struct will need custom serialization...
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 06-28-2012, 09:26 PM   #25
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Style, do you have the [XmlIgnore()] for your Color properties added as well, to signify you do custom serialization for those?
I believe I'm now using [XmlIgnore()] correctly, yet the issue remains. See the attached code.

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
I also believe your public struct will need custom serialization...
I'm not sure what you mean.

Thanks for your help!
Attached Files
File Type: zip dots.zip (3.5 KB, 4 views)
Style is offline  
Reply With Quote
Old 06-29-2012, 03:13 AM   #26
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

Yes Style, the coloring inputs should be fine, this is not what breaks it I think - the problem area is the public struct I feel, something we could also not support in our wrapper generation in NinjaScript. If you recode this area to use an enum instead you should be fine.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 06-29-2012, 06:55 AM   #27
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,218
Thanks: 24
Thanked 1,231 times in 1,002 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by Style View Post
I 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!
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.

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 at 06:29 AM. Reason: Corrected language to use proper programming lingo
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 06-29-2012, 07:27 AM   #28
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
Default

Thanks koganam, I missed those public DataSeries without an associated property...that's it.
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
Old 07-08-2012, 07:15 PM   #29
Style
Member
 
Join Date: Jul 2009
Posts: 60
Thanks: 18
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by koganam View Post
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 declare them as a Property, not as public access in the code.
That did the trick. Thanks!
Style is offline  
Reply With Quote
Reply

Tags
indicator, serializing, serializing indicators

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Serializing error mtthwbrnd Strategy Development 6 02-15-2010 11:41 AM
What does SERIALIZING INDICATORS mean? simpletrades Indicator Development 5 08-24-2009 07:31 AM


All times are GMT -6. The time now is 10:00 AM.