Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Serialize color error into condition builder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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); }
    }

    #2
    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.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      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

      Comment


        #4
        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, 08:44 AM.

        Comment


          #5
          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 Files
          JCNinjaTrader Customer Service

          Comment


            #6
            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, 02:15 AM.

            Comment


              #7
              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.
              JCNinjaTrader Customer Service

              Comment


                #8
                All right JC, thank you for it.

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

                Thank you, happy day.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by chbruno, Today, 04:10 PM
                0 responses
                3 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                6 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by frslvr, 04-11-2024, 07:26 AM
                9 responses
                127 views
                1 like
                Last Post caryc123  
                Working...
                X