I am trying to use ChartAnchor.UpdateFromPoint() to draw perfectly horizontal ray cast price lines from a drawing tool using an endAnchor set to the same price as the startAnchor point. I am also rounding the excessive decimal places off.. So same times in should be same times out - perfect horizontal line right?
Both anchor.GetPoint()s come back with equal Y values DrawingTool.GetExtendedPoint() returns a point with equal Y values. But once you use endAnchor.UpdateFromPoint() to copy it the new endAnchor extended out in time are not perfectly straight their prices come back at least 0.00002 different?
Thus crooked ray casts. I have to manually correct endAnchor.UpdateFromPoint() result... is there a bug in ChartAnchor.UpdateFromPoint()?
protected void syncEdgeAnchor() { // "Tool" is a direct reference to a DrawingTool extended class. var startAnchor = Tool.StartAnchor; var endAnchor = Tool.EndAnchor; var chartControl = Tool.ChartControl; var chartPanel = Tool.ChartPanel; var chartScale = Tool.ChartScale; roundPrice( startAnchor ); endAnchor.Price = startAnchor.Price; var startPoint = startAnchor.GetPoint( chartControl, chartPanel, chartScale ); var endPoint = endAnchor.GetPoint( chartControl, chartPanel, chartScale ); var edgePoint = /*Drawing*/Tool.GetExtendedPoint( startPoint, endPoint ); var hideAnchor = IsRight() ? anchorWidth : -anchorWidth; edgePoint.X = edgePoint.X + hideAnchor; endAnchor.UpdateFromPoint( edgePoint, chartControl, chartScale ); [B]// endAnchor.Price = startAnchor.Price; <--- I have to add this line to render perfectly straight lines.[/B] } protected static void roundPrice( ChartAnchor anchor ) { anchor.Price = Math.Round( anchor.Price, 5 ); }
Comment