here's my code.
namespace NinjaTrader.NinjaScript.Indicators
{
public class AAJQrisk : Indicator
{
private Series<double> candleSizes;
private TextFixed sizeLabel;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Show last 3 bars' range";
Name = "_JQrisk";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = false;
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.DataLoaded)
{
candleSizes = new Series<double>(this);
sizeLabel = Draw.TextFixed(this, "SizeLabel", "", TextPosition.TopRight, Brushes.White, new SimpleFont("Arial", 20), Brushes.Transparent, Brushes.Transparent, 0);
//sizeLabels = new TextFixed[3];
// for (int i = 0; i < sizeLabels.Length; i++)
// {
// sizeLabels[i] = Draw.TextFixed(this, "SizeLabel" + (i + 1).ToString(), "", TextPosition.TopRight, Brushes.White, new SimpleFont("Arial", 20), Brushes.Transparent, Brushes.Transparent, 0);
// }
}
}
protected override void OnBarUpdate()
{
if (CurrentBar >=2)
{
// double currentCandleSize = Math.Abs(High[0] - Low[0]);
// candleSizes[0] = currentCandleSize;
// double lastCandleSize = candleSizes[1];
// sizeLabel.DisplayText = "Last Candle Size: " + lastCandleSize.ToString();
double candleSize0 = Math.Abs(High[0] - Low[0]);
double candleSize1 = Math.Abs(High[1] - Low[1]);
double candleSize2 = Math.Abs(High[2] - Low[2]);
sizeLabel.DisplayText = candleSize2.ToString() + " --- " + candleSize1.ToString() + " --- " + candleSize0.ToString();
//sizeLabels[i].Point = new System.Windows.Point(ChartControl.LastBarPainted, High[i] + TickSize);
}
}
}
}

Comment