NexusFi: Find Your Edge


Home Menu

 





PlotColors serialization problem - NT7


Discussion in NinjaTrader

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




 
Search this Thread

PlotColors serialization problem - NT7

  #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?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quant vue
Trading Reviews and Vendors
NexusFi Journal Challenge - May 2024
Feedback and Announcements
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
76 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
37 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
17 thanks
  #3 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,612 since Aug 2009
Thanks Given: 11,341
Thanks Received: 2,747



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 Twitter 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,355


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, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103


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,355


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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts