Support Board
Date/Time: Sun, 12 Jan 2025 11:49:12 +0000
Post From: What is proper way to modify tool drawings of type DRAWING_LINE?
[2017-02-01 20:37:52] |
Edge Player Trading - Posts: 9 |
The following code for a study (sc.AutoLoop = 1) draws a rectangle and two vertical lines on the right side of the rectangle during processing of a single bar (although the chart type is P&F so not sure whether single bar applies). The vertical lines have text associated with them and the text appears at the top of the upward vertical line and the bottom of the downward vertical line. On subsequent bars, the code may modify these drawings by extending the rectangle and moving the vertical lines to the right. The problem I am running into is that the text of the modified downward vertical line is showing up at the top of the line rather than at the bottom of the line as was the case when it was first drawn. Also, unless the code re-adds the text associated with both lines the modified versions will not display the text associated with the original line. Any guidance on how to correct these issues will be greatly appreciated. //If new congestion pattern found, draw rectangle around congestion and //print both upside and downside targets if (CongestionFound && NewRectangle) { Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index - CongestionPatternHurdle]; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.BeginValue = sc.BaseData[SC_POINT_FIGURE_LOW][sc.Index - CongestionPatternHurdle]; Tool.EndValue = sc.BaseData[SC_POINT_FIGURE_HIGH][sc.Index]; Tool.Color = TargetsLineColor; Tool.LineStyle = TargetsLineStyle; Tool.LineWidth = TargetsLineWidth; //Draw rectangle sc.UseTool(Tool); //Save info in case rectangle/congestion pattern has to be extended NewRectangle = false; LastLineNum = Tool.LineNumber; RectangleHighLimit = Tool.EndValue + (1 * PFBoxSize); RectangleLowLimit = Tool.BeginValue - (1 * PFBoxSize); //Save target info for use below UpSideTarget = Tool.BeginValue + (CongestionPatternHurdle * PFBoxSize); DnSideTarget = Tool.EndValue - (CongestionPatternHurdle * PFBoxSize); //setup to draw vertical line to upside target Tool.LineNumber = -1; Tool.DrawingType = DRAWING_LINE; Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.BeginValue = sc.BaseData[SC_POINT_FIGURE_HIGH][sc.Index]; Tool.EndValue = UpSideTarget; Buffer.Format("%.2f", UpSideTarget); Tool.Text = Buffer; //Draw upside target vertical line at right side of rectangle sc.UseTool(Tool); //Save the line number in case this vertical line needs to be move because of //rectangle expansion UpSideTargetLineNum = Tool.LineNumber; //setup to draw vertical line to downside target Tool.LineNumber = -1; Tool.DrawingType = DRAWING_LINE; Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.BeginValue = sc.BaseData[SC_POINT_FIGURE_LOW][sc.Index]; Tool.EndValue = DnSideTarget; Buffer.Format("%.2f", DnSideTarget); Tool.Text = Buffer; //Draw downside target vertical line at right side of rectangel sc.UseTool(Tool); //Save the line number in case this vertical line needs to be move because of //rectangle expansion DnSideTargetLineNum = Tool.LineNumber; } else if (CongestionFound && !NewRectangle) //if congestion pattern expands, expand the enclosing rectangle { // Expand rectangle enclosing congestion Tool.LineNumber = LastLineNum; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; sc.UseTool(Tool); //Move vertical line to upside target Tool.LineNumber = UpSideTargetLineNum; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; // for some reason Tool does not remember text Buffer.Format("%.2f", UpSideTarget); Tool.Text = Buffer; sc.UseTool(Tool); //Move vertical line to downside target Tool.LineNumber = DnSideTargetLineNum; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.BeginDateTime = sc.BaseDateTimeIn[sc.Index]; Tool.EndDateTime = sc.BaseDateTimeIn[sc.Index]; // for some reason Tool does not remember text from original drawing // and in case of downside targets moves the text to the beginning of the line // rather than to the end of the line where it should be. Buffer.Format("%.2f", DnSideTarget); Tool.Text = Buffer; sc.UseTool(Tool); } Here is a link to a chart showing the problem: http://www.sierrachart.com/image.php?Image=1485980821353.png The rectangle and verticals on the left are un-modified. The two rectangles and verticals on the right have been modified. |