I'm probably missing something very basic, but I assumed this would work as follows: Select drawing tool (shows up fine) > click on the chart > see anchor time displayed in output window. None of that is happening, it's like my script isn't executing at all. Btw, no compile errors. Here's the code I'm using. ANY help would be appreciated since this is really basic and I'm just trying to learn how everything fits together. Thanks in advance :-)
//This namespace holds Drawing tools in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.DrawingTools
{
public class HRay : DrawingTool
{
public ChartAnchor myAnchor;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Draw horizontal ray";
Name = "HRay";
}
else if (State == State.Configure)
{
}
}
public override Cursor GetCursor(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point)
{
return Cursors.Arrow; // add your custom cursor logic here
}
public override Point[] GetSelectionPoints(ChartControl chartControl, ChartScale chartScale)
{
return new Point[0]; // add your custom selection point logic here
}
public override void OnCalculateMinMax()
{
// It is important to set MinValue and MaxValue to the min/max Y values your drawing tool uses if you want it to support auto scale
}
public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
{
NinjaTrader.Code.Output.Process("dataPoint: " + dataPoint, PrintTo.OutputTab1);
Point myPoint = dataPoint.GetPoint(chartControl, chartPanel, chartScale);
myAnchor.UpdateFromPoint(myPoint, chartControl, chartScale);
NinjaTrader.Code.Output.Process("myAnchor: " + myAnchor.Time, PrintTo.OutputTab1);
}
public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
{
// add any logic for when the mouse is moved here
}
public override void OnMouseUp(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint)
{
// add any logic for when the mouse left button is released here
}
public override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
NinjaTrader.Code.Output.Process("myAnchor: " + myAnchor.Time, PrintTo.OutputTab1);
}
}
}

Comment