NexusFi: Find Your Edge


Home Menu

 





PlotColors serialization problem - NT7


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Al2010 with 2 posts (0 thanks)
    2. looks_two ThatManFromTexas with 2 posts (4 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Fat Tails with 1 posts (4 thanks)
    1. trending_up 4,776 views
    2. thumb_up 11 thanks given
    3. group 3 followers
    1. forum 8 posts
    2. attach_file 4 attachments




 
Search this Thread
  #1 (permalink)
Al2010
 
Posts: 50 since Oct 2010
Thanks Given: 36
Thanks Received: 10

Hi,
I colored few indicators with PlotColors using Ninja help as an example. Every time I start the Ninja my colored indicators loosing colors, e.g. the rising, falling and neutral plots become transparent and I have to reset the colors in properties of the indicator. I'm not very good at programming in C# and there could be bugs in my code... Ninja provides very poor PlotColors example in online help. There is only one example on how to set static colors.
I'm attaching one of the indicators with call to PlotColors built in that loosing colors at start up. Is there an error in my code? I do not see it.
Thank you very much.


Attached Files
Elite Membership required to download: SMAColorsV7.cs
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NYSE Owner ICE Invests in Crypto Exchange OKX at $25 Bil …
Cryptocurrency
Orban at 29pct as Hungary Votes Tomorrow -- McIlroy Surg …
Prediction Markets & Event Contracts
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #3 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: NQ / ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,802 since Aug 2009
Thanks Given: 11,742
Thanks Received: 3,018



Al2010 View Post
Hi,
I colored few indicators with PlotColors using Ninja help as an example. Every time I start the Ninja my colored indicators loosing colors, e.g. the rising, falling and neutral plots become transparent and I have to reset the colors in properties of the indicator. I'm not very good at programming in C# and there could be bugs in my code... Ninja provides very poor PlotColors example in online help. There is only one example on how to set static colors.
I'm attaching one of the indicators with call to PlotColors built in that loosing colors at start up. Is there an error in my code? I do not see it.
Thank you very much.


You need to serialize the colors:

 
Code
        // Serialize our Color object
        [Browsable(false)]
        public string FallingColorSerialize
        {
            get { return NinjaTrader.Gui.Design.SerializableColor.ToString(fallingColor); }
            set { fallingColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
        }
Add code like this for each Color in the indicator.


Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,360


Al2010 View Post
Hi,
I colored few indicators with PlotColors using Ninja help as an example. Every time I start the Ninja my colored indicators loosing colors, e.g. the rising, falling and neutral plots become transparent and I have to reset the colors in properties of the indicator. I'm not very good at programming in C# and there could be bugs in my code... Ninja provides very poor PlotColors example in online help. There is only one example on how to set static colors.
I'm attaching one of the indicators with call to PlotColors built in that loosing colors at start up. Is there an error in my code? I do not see it.
Thank you very much.

You got close. Fixed it for ya.
Regards,
TMFT


I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Attached Files
Elite Membership required to download: SMAColorsV7.cs
Reply With Quote
Thanked by:
  #5 (permalink)
Al2010
 
Posts: 50 since Oct 2010
Thanks Given: 36
Thanks Received: 10

Thank you very much to all who helped.


Reply With Quote
  #6 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Interactive Brokers
Trading: Futures & Stocks
Posts: 9,887 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,114


ThatManFromTexas View Post
You got close. Fixed it for ya.
Regards,
TMFT

And now tell me, why you have put this in front of the section for the color serialization:

 
Code
[XmlIgnore()]
It is my understanding - I may be wrong - that this line will prevent the indicator from proper serialization, so if you store the indicator in a template, it might lose its color memory. The XmlIgnore() command should only be used for DataSeries objects that cannot be serialized.

Also proper serialization should make disappear the main plot, which is no longer needed. This is achieved via

 
Code
PlotsConfigurable = false;
But then you need to serialize PlotStyle, DashStyle and LineWidth separately, which I have done. Now the indicator dialogue box only shows the necessary information for the colored plot.

I have further simplified the code, and - to speed the indicator up - created an SMA object, which is initialized in OnStartUp().

Please find my fix below. Not tested for bugs.


Attached Files
Elite Membership required to download: SMAColorsV7.zip
Reply With Quote
  #7 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,360


Fat Tails View Post
And now tell me, why you have put this in front of the section for the color serialization:

 
Code
[XmlIgnore()]
It is my understanding - I may be wrong - that this line will prevent the indicator from proper serialization, so if you store the indicator in a template, it might lose its color memory. The XmlIgnore() command should only be used for DataSeries objects that cannot be serialized.

Also proper serialization should make disappear the main plot, which is no longer needed. This is achieved via

 
Code
PlotsConfigurable = false;
But then you need to serialize PlotStyle, DashStyle and LineWidth separately, which I have done. Now the indicator dialogue box only shows the necessary information for the colored plot.

I have further simplified the code, and - to speed the indicator up - created an SMA object, which is initialized in OnStartUp().

Please find my fix below. Not tested for bugs.

Because it was in the first indicator I copied from when trying to learn to code and it seemed to work...

See I told ya I wasn't a professional...... and that you write cleaner code than me ... soooo , once again I am right ...


I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
Thanked by:
  #8 (permalink)
 ghman101 
Daphne
 
Experience: Intermediate
Platform: TradeStation, TOS, Infinity, NT7
Broker: As above
Trading: ES, 6E, 6B, 6J
Posts: 144 since Apr 2010
Thanks Given: 224
Thanks Received: 84


ThatManFromTexas View Post
Because it was in the first indicator I copied from when trying to learn to code and it seemed to work...

See I told ya I wasn't a professional...... and that you write cleaner code than me ... soooo , once again I am right ...

Just got this error from NT7 on ADXVMA_Sharky_Paint > I went to save my NT workspace and got this > 2011-04-14_1212 - GregHohman's library


Attached Files
Elite Membership required to download: ADXVMA_sharky_paintbar.zip
Reply With Quote
  #9 (permalink)
microsat
houston texas/us
 
Posts: 25 since Dec 2014
Thanks Given: 6
Thanks Received: 2

Can we use the SMAColorsV7's PlotColors as strategy trigger?

like
if (SMAColorsV7.PlotColors[0][0] == Color.Red)
EnterShort();



Fat Tails View Post
And now tell me, why you have put this in front of the section for the color serialization:

 
Code
[XmlIgnore()]
It is my understanding - I may be wrong - that this line will prevent the indicator from proper serialization, so if you store the indicator in a template, it might lose its color memory. The XmlIgnore() command should only be used for DataSeries objects that cannot be serialized.

Also proper serialization should make disappear the main plot, which is no longer needed. This is achieved via

 
Code
PlotsConfigurable = false;
But then you need to serialize PlotStyle, DashStyle and LineWidth separately, which I have done. Now the indicator dialogue box only shows the necessary information for the colored plot.

I have further simplified the code, and - to speed the indicator up - created an SMA object, which is initialized in OnStartUp().

Please find my fix below. Not tested for bugs.


Reply With Quote




Last Updated on August 4, 2015


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts