For example, the default color is Blue, but I add an indicator and change the color to Red. When I save as a template, and then load the template elsewhere, the color reverts to blue.
Here some sample code that draws a simple line at certain times. Bolded parts are the likely important lines. Can someone help me here or point to some documentation which would lead me in the right direction? Thanks.
region Using declarations
using NinjaTrader.Data;
using NinjaTrader.Gui;
using SharpDX.Direct2D1;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using System.Xml.Serialization;
#endregion
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators.MyIndicators
{
public class D_draw : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"PriceDraw";
Name = "PriceDraw";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
PaintPriceMarkers = true;
IsSuspendedWhileInactive = true;
MyBrush = Brushes.Blue;
}
else if (State == State.Configure)
{
AddPlot(new Stroke(MyBrush, DashStyleHelper.Solid, 1), PlotStyle.Dot, "D_draw");
AddDataSeries(BarsPeriodType.Minute, 1);
}
}
private double _plotValue = 0;
protected override void OnBarUpdate()
{
if (CurrentBars[1] < 1000)
{ return; }
if (BarsPeriod.BarsPeriodType == BarsPeriodType.Minute && BarsPeriod.Value == 1) //Only look at 1Min bars regardless of chart
{
int BarMinute = Time[0].Minute;
int BarHour = Time[0].Hour;
int BarDay = Time[0].Day;
int BarMonth = Time[0].Month;
int BarYear = Time[0].Year;
int open = CurrentBar - Bars.GetBar(new DateTime(BarYear, BarMonth, BarDay, PlotHour, 0, 0)); //Open Time example 800 cst
// check to see if matches
if (PlotHour == BarHour & PlotMinute == BarMinute)
{
_plotValue = Closes[1][0];
Print("Plotvalue: " + BarDay.ToString() + " day & value: " + _plotValue.ToString());
}
if(_plotValue > 0)
{
Values[0][0] = _plotValue;
}
}
}
region Properties
[Range(0, int.MaxValue)]
[NinjaScriptProperty]
[Display(Name = "EventHour", Description = "Hour of Event", Order = 1, GroupName = "Parameters")]
public int PlotHour
{ get; set; }
[Range(0, int.MaxValue)]
[NinjaScriptProperty]
[Display(Name = "EventMinute", Description = "Minute of Event", Order = 2, GroupName = "Parameters")]
public int PlotMinute
{ get; set; }
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public double TheOpen
{
get; set;
}
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public double o
{
get; set;
}
[XmlIgnore]
[Display(Name = "MyBrush", Description = "Color of the Event Marker", Order = 1, GroupName = "Parameters")]
public System.Windows.Media.Brush MyBrush
{ get; set; }
#endregion
}
Comment