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

NT8 color to Brush conversion with Opacity

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

    #31
    Originally posted by NinjaTrader_Kate View Post
    Hello dj22522,

    Thank you for your reply.

    This all looks correct - can you supply an export of the script so we may test on our end? You can export it from Tools > Export > NinjaScript Addon. Do not check the box to export as a compiled assembly or we will not be able to review the logic. Please attach the resulting .Zip file to your reply.

    Thanks in advance; I look forward to assisting you further.
    Thank you for the quick reply.

    Can I email you the zip file ?

    If so which email address can I send to ?

    Many thanks

    Comment


      #32
      Hello dj22522,

      Thank you for your reply.

      If you'd prefer not to post it here, you may email it to us directly at scriptingsupport [at] ninjatrader [dot] com. Please include 3419845 ATTN Kate W. in the subject line and a link to this post in the body of the email.

      Thanks in advance; I look forward to assisting further.
      Kate W.NinjaTrader Customer Service

      Comment


        #33
        Originally posted by dj22522 View Post


        Thank you for the reply Kate

        Yes I have created inputs.

        Assuming I've done this correctly I have the following :

        protected override void OnStateChange()
        {
        if (State == State.SetDefaults) :

        Code:
         protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        
        BackColourUp = Brushes.Blue;
        BackColourDn = Brushes.Red;
        BackgroundOpacity = 15; // 15% as default value
        
        {


        I then have the following in
        else if (State == State.Configure)


        Code:
        else if (State == State.Configure)
        {
        
        Brush temp = BackColourUp.Clone();
        temp.Opacity = BackgroundOpacity / 100.0;
        temp.Freeze();
        BackColourUp = temp;
        
        Brush temp1 = BackColourDn.Clone();
        temp1.Opacity = BackgroundOpacity / 100.0;
        temp1.Freeze();
        BackColourDn = temp1;
        
        
        }


        I have the following in Properties:

        Code:
        [NinjaScriptProperty]
        [Display(Name="Back colour Up", Description="", Order=3, GroupName="Back Colour")]
        public Brush BackColourUp
        { get; set; }
        
        [Browsable(false)]
        public string BackColourUpSerializable
        {
        get { return Serialize.BrushToString(BackColourUp); }
        set { BackColourUp = Serialize.StringToBrush(value); }
        }
        
        [NinjaScriptProperty]
        [Display(Name="Back colour Down", Description="", Order=4, GroupName="Back Colour")]
        public Brush BackColourDn
        { get; set; }
        
        [Browsable(false)]
        public string BackColourDnSerializable
        {
        get { return Serialize.BrushToString(BackColourDn); }
        set { BackColourDn = Serialize.StringToBrush(value); }
        }
        
        
        //Opacity
        [Range(0, 100)]
        [Display(Name="Back colour Opacity", Description="", Order=5, GroupName="Back Colour")]
        public int BackgroundOpacity
        { get; set; }

        What am I doing wrong ?

        Many thanks


        I've solved the issue of the indicator not saving after having applied the above code for Background and Opacity.

        [XmlIgnore] was missing from the BackColourUp and BackColourDn Properties.


        Here is the correct code:

        Many thanks to nothingbutprofits for the original code and to NT Kate for being so responsive.


        Enjoy


        Code:
        [NinjaScriptProperty]
        [Display(Name="Back Colour Panel", Description="", Order=1, GroupName="Back Colour AVG < > 0")]
        public bool ColorBackground
        { get; set; }
        
        [NinjaScriptProperty]
        [Display(Name="Back Colour All", Description="", Order=2, GroupName="Back Colour AVG < > 0")]
        public bool ColorBackgroundAll
        { get; set; }
        
        [NinjaScriptProperty]
        [XmlIgnore]
        [Display(Name="> 0", Description="", Order=3, GroupName="Back Colour AVG < > 0")]
        public Brush BackColourUp
        { get; set; }
        
        [Browsable(false)]
        public string BackColourUpSerializable
        {
        get { return Serialize.BrushToString(BackColourUp); }
        set { BackColourUp = Serialize.StringToBrush(value); }
        }
        
        [NinjaScriptProperty]
        [XmlIgnore]
        [Display(Name="< 0", Description="", Order=4, GroupName="Back Colour AVG < > 0")]
        public Brush BackColourDn
        { get; set; }
        
        [Browsable(false)]
        public string BackColourDnSerializable
        {
        get { return Serialize.BrushToString(BackColourDn); }
        set { BackColourDn = Serialize.StringToBrush(value); }
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jonker, Today, 01:19 PM
        0 responses
        1 view
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        5 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,791 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        844 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,296 views
        1 like
        Last Post jgualdronc  
        Working...
        X