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

Shade colour not being remembered

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

    Shade colour not being remembered

    Hi

    I have an indicator that draws a coloured region beteen Bollinger Band upper and lower series. I set the colour and opacity of the shaded region (and also the Bollinger Band parameters) via input parameters.

    When I use the indicator on a chart with settings different from the defaults, all is OK until I close the workspace and re-open it. The colour reverts to the default colour even though the opacity and Bollinger Band parameters are remembered.

    How do I get the setting for region colour to persist?

    Cheers
    Tony

    Here are sections from the code:

    private double numStdDev = 2;
    private int period = 14;
    private Color shadeColour = Color.CornflowerBlue;
    private int shadeOpacity = 2;
    ...
    protected override void OnBarUpdate()
    {
    DrawRegion( "Area", CurrentBar, 0, Bollinger( numStdDev, period ).Upper, Bollinger( numStdDev, period ).Lower,
    shadeColour, shadeColour, shadeOpacity );
    }
    ...
    [XmlIgnore()]
    [Description("Colour of the shading.")]
    [GridCategory("Parameters")]
    public Color ShadeColour
    {
    get { return shadeColour; }
    set { shadeColour = value; }
    }

    #2
    Hello JellyBean,

    Thanks for your post about color persistence.

    In C#, which NinjaScript is based on, the colors must be serialized to retain their state when the program is shutdown, otherwise as you have observed all it knows is the default color.

    Here is a link that states the purpose of serialization: http://msdn.microsoft.com/en-us/library/ms233843.aspx

    I have copied your color part of the properties and added the needed serialization statements.
    Code:
    [XmlIgnore()]
    [Description("Colour of the shading.")]
    [GridCategory("Parameters")]
    public Color ShadeColour
    {
    get { return shadeColour; }
    set { shadeColour = value; }
    }
    
    [B][Browsable(false)]
    public string shadecolourSerialize
    {
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString(Shadecolour); }
    set { Shadecolour = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    }[/B]
    For another reference, here is a NinjaTrader tip file: http://www.ninjatrader.com/support/f...ead.php?t=4977

    Please let me know if need any further assistance.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, Today, 10:57 PM
    0 responses
    1 view
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Today, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Working...
    X