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

Indicator settings get cleared when saved as chart template

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

    Indicator settings get cleared when saved as chart template

    I created an indicator the combines the keyReversalUp and keyReversalDown indicators and then paints the bars for up, down and neutral. The indicator works fine, but when I save as a template and then load the template the barColor settings are cleared and the bars are not colored correctly. If I remove the indicator and add it again everything is ok.

    The images are the Indicators settings and chart when applying the indicator and when applying a saved template that includes the indicator.

    Code:
            #region Variable
                private int lookback = 5;			// Lookback period for reversal bar to break previous Hi/Lo to generate signal
    			private Color		reversalUp 		= Color.Blue;
    			private Color		reversalDown 	= Color.Red;
    			private Color		reversalNeut 	= Color.Gray;
    			private Color		reversalColor	= Color.Empty;
            #endregion
    
            #region Initialize
    			/// <summary>
    			/// This method is used to configure the indicator and is called once before any bar data is loaded.
    			/// </summary>
    			protected override void Initialize()
    			{
    				Add(new Plot(Color.Transparent, PlotStyle.Bar, "ReversalBars"));	// Overlay the indicator and plot as transparent
    				PaintPriceMarkers = false;
    				Overlay = true;
    				ScaleJustification = ScaleJustification.Overlay;	// Makes overlay of indicator overlap price panel w/o changing scale
    			}
    Code:
    				// Set bar colors
    				PlotColors[0][0] = Color.Transparent;	// Don't plot the -1,1 values for Reversals
    				if(Value[0] == -1)
    					reversalColor = reversalDown;
    				else if(Value[0] == 1)
    					reversalColor = reversalUp;
    				else
    					reversalColor = reversalNeut;
    				
    				if(Open[0] < Close[0])	BarColor = Color.Transparent;
    				else BarColor = reversalColor;
    				CandleOutlineColor = reversalColor;
    Attached Files

    #2
    Hello tjw0001,

    While this is not in the code you posted, it may be that the color inputs are made public and are not serialized properly.

    It looks that somehow these colors can be changed by the user which means they are made public.

    Below is a link to a forum thread of serializing color inputs that are made public.
    http://www.ninjatrader.com/support/f...ead.php?t=4977

    Let me know if these colors are not made into public inputs.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Adding "[XmlIgnore()]" in the "Properties" region before the Color variables solved the problem.
      Code:
      			[XmlIgnore()]
      			[Description("Color for Up Reversal Bar")]
      			[Category("Plots")]
      			[Gui.Design.DisplayNameAttribute("1. Up Reversal Bar Color")]
      			public Color ReversalUp
      			{
      				get { return reversalUp; }
      				set { reversalUp = value; }
      			}

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ninza33, Today, 12:31 PM
      2 responses
      9 views
      0 likes
      Last Post ninza33
      by ninza33
       
      Started by Bobin, 03-12-2024, 08:51 AM
      15 responses
      480 views
      0 likes
      Last Post fiddich
      by fiddich
       
      Started by Skifree, Today, 11:21 AM
      4 responses
      13 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by Bogdan097, Today, 03:25 PM
      0 responses
      3 views
      0 likes
      Last Post Bogdan097  
      Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
      25 responses
      127 views
      0 likes
      Last Post cmtjoancolmenero  
      Working...
      X