Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      579 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X