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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 08-22-2012, 01:43 PM   #1
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default Serialize color error into condition builder

Hi!

I serialize a public Color in an indicator for can choose in parameters. Its ok, but when i call the indicator properties from conditions builder of strategies wizard the color shows as a string in quotes:

For ex: 'Color [DodgerBlue]'

and i need to select other color, and change to DodgerBlue

If i dont change the strategy compilation launch an error.

Its possible to avoid this issue?
more better, its possible to avoid all unnecessary parameters in condition builder?

THank you



My code:

Declaring colors:

private Color longsignalcolor = Color.DodgerBlue;
private Color shortsignalcolor = Color.Magenta;



Into properties:

//Color shortsignalcolor
[Description("Color for short signal arrow")]
[GridCategory("Parameters")]
public Color ShortSignalColor{
get { return shortsignalcolor; }
set { shortsignalcolor = value; }
}
// Serialize our Color object
[Browsable(false)]
public string ShortSignalColorSerialize{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString( ShortSignalColor); }
set { ShortSignalColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
}
marynja is offline  
Reply With Quote
Old 08-22-2012, 01:58 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

marynja,

Please see the following for more information on how to fix that, basically you are missing a piece of XML code which is outlined at the link below.

http://www.ninjatrader.com/support/f...ead.php?t=4977
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 08-24-2012, 08:34 AM   #3
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default

Thanks Adam. i am using the [XmlIgnore()] before Color declaration but dont work.

If i write [XmlIgnore()] before Serialize instead of the Color declaration (as in your example), the problem its the same but the value now show as this: 'Color [Empty]'

Some idea? Thanks again
marynja is offline  
Reply With Quote
Old 08-24-2012, 08:40 AM   #4
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default

I instaling the example indicator and call into Condition Builder.
Please, look the image and how the wizard tak a string value for color. If i finish the wizard launch an error on generating the strategy.


Last edited by marynja; 08-24-2012 at 08:44 AM.
marynja is offline  
Reply With Quote
Old 08-24-2012, 10:05 AM   #5
NinjaTrader_JC
NinjaTrader Customer Service
 
NinjaTrader_JC's Avatar
 
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,200
Thanks: 137
Thanked 183 times in 182 posts
Default

Hello marynja,

You could receive an error for two reasons using the SampleColorInput.

1. SampleColorInput does not contain a Plot() which is going to be needed since you are comparing it to a value. So you may receive the following error: "'System.Drawing.Color' is a 'type' but is used like a 'variable'"

2. When you are choosing a color(s) you would want to use the "Web" tab to be able to select a color for your strategy. See attached image.

Let us know if we can be of further assistance.
Attached Images
File Type: png ConditionBuilderSerialColor.png (70.8 KB, 5 views)
NinjaTrader_JC is offline  
Reply With Quote
Old 08-24-2012, 05:05 PM   #6
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default

I kown JC, and thanks.

If i select a web color, then the strategy compile correctly.

But maybe i dont explain well. I dont understan why i need to correct this error all the times when i use my indicator in the strategy wizard. When i declare the color is a web color.

I know that isnt a plot(), and i dont need in my strategy, is for it i want to hidde into Condition Builder.

Its possible to hidde this useless params? or its possible the initial color value be correct as same as i select a web color?

Thanks again
Last edited by marynja; 08-25-2012 at 02:15 AM.
marynja is offline  
Reply With Quote
Old 08-27-2012, 07:59 AM   #7
NinjaTrader_JC
NinjaTrader Customer Service
 
NinjaTrader_JC's Avatar
 
Join Date: Mar 2012
Location: Denver, CO
Posts: 1,200
Thanks: 137
Thanked 183 times in 182 posts
Default

Hello marynja,

This is because the Strategy Wizard was not designed to handle color inputs. If you do not want to have it as a select able parameter you may want to create another indicator that does not need to take a color as a parameter that needs to be passed to it.

Happy to be of further assistance.
NinjaTrader_JC is offline  
Reply With Quote
The following user says thank you to NinjaTrader_JC for this post:
Old 08-27-2012, 10:11 AM   #8
marynja
Member
 
Join Date: Jan 2011
Posts: 54
Thanks: 14
Thanked 0 times in 0 posts
Default

All right JC, thank you for it.

I pray to NT developers to fix this bug for new versions.

Thank you, happy day.
marynja is offline  
Reply With Quote
Reply

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
condition builder help jtrotter33 Strategy Development 7 12-06-2011 08:42 AM
Cant serialize error gg80108 Indicator Development 1 12-02-2010 08:30 AM
Serialize error monpere Indicator Development 5 06-23-2008 07:35 PM
price data ERROR dialog box in condition builder Bob10 Miscellaneous Support 4 01-29-2008 06:17 PM
Condition Builder - Time Comparison Error davidfw1866 Strategy Development 4 10-30-2007 07:16 AM


All times are GMT -6. The time now is 01:27 PM.