I want to draw a line in a chart from the point I click with the mouse until the end of the right side of the chart while the mouse button is clicked.
I have this code written for the mouse event.
protected void MouseClicked(object sender, MouseButtonEventArgs e) { try { // convert e.GetPosition for different dpi settings clickPoint.X = ChartingExtensions.ConvertToHorizontalPixels(e.Get Position(ChartPanel as IInputElement).X, ChartControl.PresentationSource); clickPoint.Y = ChartingExtensions.ConvertToVerticalPixels(e.GetPo sition(ChartPanel as IInputElement).Y, ChartControl.PresentationSource); double precioenClick = Instrument.MasterInstrument.RoundToTickSize(chartS cale.GetValueByY((float)clickPoint.Y)); Point punto2 = new Point(ChartControl.CanvasRight, chartScale.GetYByValue(precioenClick)); RenderTarget.DrawLine(clickPoint.ToVector2(), punto2.ToVector2(), Brushes.Aqua.ToDxBrush(RenderTarget)); e.Handled = true; } catch (Exception exception) { // In case the indicator has already been Terminated, you can safely ignore errors if (State >= State.Terminated) return; /* With our caught exception we are able to generate log entries that go to the Control Center logs and also print more detailed information about the error to the Output Window. */ // Submits an entry into the Control Center logs to inform the user of an error Log(Name+ " MOUSECLICKED Error: Please check your indicator for errors.", NinjaTrader.Cbi.LogLevel.Warning); // Prints the caught exception in the Output Window Print(Name+ " ONMOUSE CLICK " +Time[0] + " " + exception.ToString()+exception.StackTrace); } }
Parameter name: renderTarget
at NinjaTrader.Gui.DxExtensions.ToDxBrush(Brush brush, RenderTarget renderTarget, Single opacity)
Thanks
Comment