I'm getting following error in lines 23 and 57 "The name 'Brushes' does not exist in the current context". Could you please point me in the direction what I'm doing wrong here?
#region Using declarations
using System;
using NinjaTrader.Gui.Chart;
using NinjaTrader.NinjaScript;
using NinjaTrader.Data;
using NinjaTrader.Gui.Tools;
using SharpDX;
using SharpDX.DirectWrite;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
namespace NinjaTrader.NinjaScript.Indicators
{
public class BarRangeBodyRatio : Indicator
{
private SimpleFont textFont;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Displays the ratio of bar range to bar body size in the top right corner.";
AddPlot(Brushes.Transparent, "Ratio");
}
else if (State == State.Configure)
{
textFont = new SimpleFont("Arial", 14) { Bold = true };
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;
double barRange = High[0] - Low[0];
double bodySize = Math.Abs(Close[0] - Open[0]);
double ratio = bodySize > 0 ? barRange / bodySize : 0;
Values[0][0] = ratio;
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
base.OnRender(chartControl, chartScale);
if (Bars == null || Bars.Count < 1 || chartControl == null)
return;
string text = $"Range/Body: {Values[0][0]:0.00}";
// Set the position for top-right corner display
float xPos = chartControl.CanvasRight - 150; // Position from right edge
float yPos = 10; // Position from top
// Draw text on the chart
RenderTarget.DrawText(text, textFont, new SharpDX.RectangleF(xPos, yPos, 200, 50), Brushes.Black.ToDxBrush(RenderTarget));
}
}
}

Comment