Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    592 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X