Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Brush field in Strategy Analyzer

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

    Brush field in Strategy Analyzer

    Hi,

    I'm having problem with Brush field resetting to default value after run in Strategy Analyzer.

    See attached sample strategy.

    I open Strategy Analyzer window, change integer and Brush values (before_pressing_run screenshot) and press Run. After completion (after_pressing_run screenshot) integer value stays but Brush value reverts to default one.

    What am I doing wrong?
    Attached Files

    #2
    Hello glivv,

    Thank you for your note.

    I revised your script and provided the correct way to go about taking a brush input as well as serializing it.

    Code:
    private	Brush boxColor = Brushes.Green;
    		
    		[XmlIgnore()]
    		[NinjaScriptProperty]
    		[Display(Description = "BoxColor", GroupName = "Parameters", Order = 4)]
    		public Brush BoxColor
    		{
    			get{return boxColor;}
    			set{boxColor = value;}
    		}
    		
    		[Browsable(false)]
    		public string BoxColorBelowSerialize
    		{
    			get{return Serialize.BrushToString(boxColor);}
    			set{boxColor = Serialize.StringToBrush(value);}
    		}
    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      So, unlike any other (like integer or string) properties, Brush property cannot be set in "State == State.SetDefaults" branch in OnStateChange()?

      Comment


        #4
        Hello glivv,

        If you add the print statement in the screen shot within SetDefaults and open an output window, then pull up a strategy analyzer and queue up the strategy, run the analyzer, you will see how often this block is ran. Setting the value within SetDefaults is going to cause the brush to be set back to this value.

        You should set the value of the brush outside of State.SetDefaults.

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hello Allan

          even if I use code per your suggestions, i.e.:

          Code:
          namespace NinjaTrader.NinjaScript.Strategies
          {
          	public class TstBrush : Strategy
          	{
          		private	Brush boxColor = Brushes.Green;
          		
          		[XmlIgnore()]
          		[NinjaScriptProperty]
          		[Display(Description = "BoxColor", GroupName = "Parameters", Order = 4)]
          		public Brush BoxColor
          		{
          			get{return boxColor;}
          			set{boxColor = value;}
          		}
          		
          		[Browsable(false)]
          		public string BoxColorBelowSerialize
          		{
          			get{return Serialize.BrushToString(boxColor);}
          			set{boxColor = Serialize.StringToBrush(value);}
          		}
          		
          		protected override void OnStateChange()
          		{
          		}
          	}
          }
          I still see that BoxColor input is reverted back to default value after run in Strategy Analyzer.

          That is, open Strategy Analyzer, choose TstBrush strategy, change BoxColor from Green to any other value, White for example, select symbol/timeframe/period and press Run. When backtest finishes, BoxColor input is reverted to Green. It doesn't stay at White.

          Comment


            #6
            Helllo glivv,

            I am currently looking into this and will follow up when I have more information.

            Thank you for your patience.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Hello glivv,

              Thank you for your patience.

              I have reported this as a bug and will follow up with you when I have more information.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Hello glivv,

                This bug is assigned an ID of, 12485, which you can check the helpguide for under the release notes at the following link,


                I wouldn't be able to say when its slated to be fixed however if you check the release notes in the next release you may find that number...

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello glivv,

                  Thank you for your patience.

                  The solution as of now is to use a solid brush color.

                  I have attached a script which will hold its color.

                  Code:
                  [XmlIgnore()]
                  		[Display(Name = "FillBrush", GroupName = "NinjaScriptParameters", Order = 1)]
                  		public SolidColorBrush FillBrush
                  		{ get; set; }		
                  		
                  		[Browsable(false)]
                  		public string FillBrushSerialize
                  		{
                  			get { return Serialize.BrushToString(FillBrush); }
                     			set { FillBrush = (SolidColorBrush)Serialize.StringToBrush(value); }
                  		}
                  Please let us know if you need further assistance.
                  Attached Files
                  Alan P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by e5656, Today, 01:00 PM
                  2 responses
                  34 views
                  0 likes
                  Last Post e5656
                  by e5656
                   
                  Started by sarderiftekhar, Today, 04:11 AM
                  2 responses
                  14 views
                  0 likes
                  Last Post sarderiftekhar  
                  Started by srhserio33, Today, 04:24 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post srhserio33  
                  Started by NISNOS69, 10-03-2024, 05:38 AM
                  23 responses
                  77 views
                  0 likes
                  Last Post NISNOS69  
                  Started by samish18, Today, 10:47 AM
                  6 responses
                  18 views
                  0 likes
                  Last Post samish18  
                  Working...
                  X