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 fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X