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

Custom Color Plotting - Saving Preferences and Overriding defaults

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

    Custom Color Plotting - Saving Preferences and Overriding defaults

    Hello:

    I have multiple custom indicators that have plots with alternating colors based on certain market conditions. For example, I have a paint bar system that paints the candle bar 4 different colors based on core logic. I have these variables declared as follows:

    private Brush _upColor;
    private Brush _dwnColor;
    private Brush _volSpikeUpColor;
    private Brush _volSpikeDownColor;
    I have the defaults set under the on state change event were State == State.SetDefaults as follows:

    _upColor = Brushes.CornflowerBlue;
    _dwnColor = Brushes.Crimson;
    _volSpikeUpColor = Brushes.Lime;
    _volSpikeDownColor = Brushes.Magenta;
    Everything is working fine, calculating and plotting correctly - with the correct color with one small annoying exception.

    When a user decides to change the default colors by going to the settings (CONTROL+I) they are able to do so successfully and the indicator once again plots correctly with the newly selected color. HOWEVER, when the user closes NT8, even after saving the workspace, and reloads it, the old default colors are being used and not the ones the user changed it to. The settings for the colors are coded as follows:

    [Display(ResourceType = typeof(Custom.Resource), Name = "Up Color", GroupName = "Settings Colors", Order = 0), XmlIgnore]
    public Brush UpColor
    {
    get { return _upColor; }
    set { _upColor = value; }
    }

    [Browsable(false), XmlIgnore]
    public string UpColorSerialize
    {
    get { return Serialize.BrushToString(_upColor); }
    set { _upColor = Serialize.StringToBrush(value); }
    }

    [Display(ResourceType = typeof(Custom.Resource), Name = "Down Color", GroupName = "Settings Colors", Order = 0), XmlIgnore]
    public Brush DownColor
    {
    get { return _dwnColor; }
    set { _dwnColor = value; }
    }

    [Display(ResourceType = typeof(Custom.Resource), Name = "Up Volume Spike", GroupName = "Settings Volume", Order = 0), XmlIgnore]
    public Brush volSpikeUpColor
    {
    get { return _volSpikeUpColor; }
    set { _volSpikeUpColor = value; }
    }

    [Browsable(false), XmlIgnore]
    public string volSpikeUpColorSerialize
    {
    get { return Serialize.BrushToString(_volSpikeUpColor); }
    set { _volSpikeUpColor = Serialize.StringToBrush(value); }
    }

    [Display(ResourceType = typeof(Custom.Resource), Name = "Down Volume Spike", GroupName = "Settings Volume", Order = 1), XmlIgnore]
    public Brush volSpikeDownColor
    {
    get { return _volSpikeDownColor; }
    set { _volSpikeDownColor = value; }
    }

    [Browsable(false), XmlIgnore]
    public string volSpikeDownColorSerialize
    {
    get { return Serialize.BrushToString(_volSpikeDownColor); }
    set { _volSpikeDownColor = Serialize.StringToBrush(value); }
    }

    [Display(ResourceType = typeof(Custom.Resource), Name = "Alerts On", GroupName = "Settings Volume", Order = 3), XmlIgnore]
    public bool volAlert
    {
    get { return _volAlert;}
    set { _volAlert = value;}
    }


    [Display(ResourceType = typeof(Custom.Resource), Name = "Volume Threshold", GroupName = "Settings Volume", Order = 2), XmlIgnore]
    public double volThreshold
    {
    get { return _volThreshold;}
    set { _volThreshold = value;}
    }
    What I am looking to accomplish is to allow the user to select colors other than the defaults that are provided with the indicator and for those colors to presist after NT8 is shutdown and reloaded. It seems saving the workspace is not working. At present, everytime NT8 is reloaded - the colors have to be changed again.

    Thanks

    #2
    Originally posted by MarthaClines View Post
    Hello:

    I have multiple custom indicators that have plots with alternating colors based on certain market conditions. For example, I have a paint bar system that paints the candle bar 4 different colors based on core logic. I have these variables declared as follows:



    I have the defaults set under the on state change event were State == State.SetDefaults as follows:



    Everything is working fine, calculating and plotting correctly - with the correct color with one small annoying exception.

    When a user decides to change the default colors by going to the settings (CONTROL+I) they are able to do so successfully and the indicator once again plots correctly with the newly selected color. HOWEVER, when the user closes NT8, even after saving the workspace, and reloads it, the old default colors are being used and not the ones the user changed it to. The settings for the colors are coded as follows:



    What I am looking to accomplish is to allow the user to select colors other than the defaults that are provided with the indicator and for those colors to presist after NT8 is shutdown and reloaded. It seems saving the workspace is not working. At present, everytime NT8 is reloaded - the colors have to be changed again.

    Thanks
    This is because Ninja on restart uses the default indicator templates.

    One easy way is to set the custom colors as desired then in the indicator properties window click on template (at bottom right corner) and save the template as Default. And you have it, your custom colors will show on restart.

    If you want to go back to the original settings then click on template then click reset to go back to original colors.

    Cheers!

    Comment


      #3
      Hello MarthaClines,
      Thanks for your post.

      It looks like you are using the XMLIgnore Attribute with your brush properties which would prevent those properties from being saved in a template or workspace.

      Josh G.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_JoshG View Post
        Hello MarthaClines,
        Thanks for your post.

        It looks like you are using the XMLIgnore Attribute with your brush properties which would prevent those properties from being saved in a template or workspace.

        https://ninjatrader.com/support/help...eattribute.htm
        WOW thanks you Mr Josh - the XmLIgnore attribute was the issue. Working like a champ now

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        67 views
        0 likes
        Last Post tsantospinto  
        Started by cre8able, Today, 03:20 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        49 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        115 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by The_Sec, Today, 02:29 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X