This is a piece of code to show you what I'm what I'm doing wrong trying to apply the font script example.
If you could tell me what I'm doing wrong, that would be wonderful. Thanks
public class MyDistance : Indicator
{
private NinjaTrader.Gui.Tools.SimpleFont myFont;
//class level variable
private double MyDifferenceGreen;
private double MyDifferenceRed;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyDistance";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 30, Bold = true };
}
}
protected override void OnBarUpdate()
{
//assign MyDifference
int MyDifferenceGreen = (int)((Close[0] - Open[0]) / TickSize);
int MyDifferenceRed = (int)((Open[0] - Close[0]) / TickSize);
//red ticks
if (Open[0] >= Close[0])
Draw.Text(this, "distance" + CurrentBar, false, MyDifferenceRed.ToString(), 0, High[0] + 15 * TickSize, Brushes.Red, myFont, TextAlignment.Center, null, null, 1);
//green ticks
if (Close[0] > Open[0])
Draw.Text(this, "distance" + CurrentBar, false, MyDifferenceGreen.ToString(), 0, Low[0] - 15 * TickSize, Brushes.ForestGreen, myFont, TextAlignment.Center, null, null, 1);
} }
}

Comment