Support Board
Date/Time: Sun, 24 Nov 2024 22:53:36 +0000
[Programming Help] - Issue with UseTool - PLEASE HELP
View Count: 441
[2024-02-25 18:46:32] |
sampater - Posts: 244 |
I have an old study that draws rectangles and text using the UseTool. Everything worked fine in version 2068. After updating the Sierra Chart began to appear text from other call UseTool. My guess is that as a result of the Chartbook file format change, the function Tool.Clear() for the Tool.DrawingType = DRAWING_TEXT broke down. Also the Tool.Text for other Tool.DrawingType couse the issue. It's also possible that Tool.TextAlignment is causing the problem. Example code showing the problem: SCSFExport scsf_DrawingMarker(SCStudyInterfaceRef sc) { SCInputRef Color1 = sc.Input[1]; SCInputRef Color2 = sc.Input[2]; if (sc.SetDefaults) { sc.GraphName = "Drawing Marker"; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.FreeDLL = 0; Color1.Name = "Color 1"; Color1.SetColor(0,200,0); Color2.Name = "Color 2"; Color2.SetColor(255,0,0); return; } s_UseTool Tool; // Drawing Text Tool.Clear(); Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.LineNumber = 1; Tool.DrawingType = DRAWING_TEXT; Tool.FontSize = 8; Tool.Color = Color1.GetColor(); Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.High[sc.Index]; Tool.Text = " TEXT "; Tool.TextAlignment = DT_CENTER | DT_VCENTER; sc.UseTool(Tool); // Drawing Marker Tool.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; Tool.LineNumber = 2; Tool.DrawingType = DRAWING_MARKER; Tool.MarkerType = MARKER_X; Tool.Color = Color2.GetColor(); Tool.MarkerSize = 6; Tool.LineWidth = 3; Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.Low[sc.Index]; sc.UseTool(Tool); } https://www.sierrachart.com/image.php?Image=1708886239631.png Date Time Of Last Edit: 2024-02-28 23:25:46
|
[2024-02-28 22:07:21] |
sampater - Posts: 244 |
Sierra Chart Engineering, Could you please to check why there is an error in drawing drawings using UseTool. The code above shows this error. The study draws three objects, while it should draw only two: 1) First, it correctly draws "TEXT" (green color) by Tool.DrawingType = DRAWING_TEXT. 2) Then it correctly draws Marker X (red color) by Tool.DrawingType = DRAWING_MARKER. 3) And then, incorrectly duplicates "TEXT" (red color) even though Tool.Clear() function was used. This problem did not occur when I used an old version of Sierra Chart (e.g. version 2068). I checked it again. This example code draws differently in the old version than in the new version. Thank yuo very much ! Date Time Of Last Edit: 2024-02-28 22:15:42
|
[2024-02-28 22:57:39] |
User719512 - Posts: 264 |
There are a few things going on here. 1) you should follow the patterns in the samples and save the LineNumber in a persistent (but that is not the cause of your issue) 2) you could make your drawings User Drawings, and better see what is happening via inspection. (I updated your code to do so for debugging purposes) 3) Once user drawings, you can see them in the manage user drawings dialog, Ctrl-Alt-M, and see that the red TEXT is text on the X marker, not a 3rd drawing. 4) Looks like Tool.Clear() does not reset Tool.Text. That seems like a bug to me. Adding Tool.Text.Clear() seems to resolve that and can be used till Sierra fixes this bug. Below is updated code... SCSFExport scsf_DrawingMarker(SCStudyInterfaceRef sc) { SCInputRef Color1 = sc.Input[1]; SCInputRef Color2 = sc.Input[2]; if (sc.SetDefaults) { sc.GraphName = "Drawing Marker"; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.FreeDLL = 0; Color1.Name = "Color 1"; Color1.SetColor(0, 200, 0); Color2.Name = "Color 2"; Color2.SetColor(255, 0, 0); return; } s_UseTool Tool; int& r_LineNumber1 = sc.GetPersistentInt(1); int& r_LineNumber2 = sc.GetPersistentInt(2); // Drawing Text Tool.Clear(); Tool.Text.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; if (r_LineNumber1 != 0) Tool.LineNumber = r_LineNumber1; Tool.DrawingType = DRAWING_TEXT; Tool.FontSize = 8; Tool.Color = Color1.GetColor(); Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.High[sc.Index]; Tool.Text = " TEXT "; Tool.TextAlignment = DT_CENTER | DT_VCENTER; Tool.AddAsUserDrawnDrawing = 1; sc.UseTool(Tool); r_LineNumber1 = Tool.LineNumber;//Remember line number which has been automatically set // Drawing Marker Tool.Clear(); Tool.Text.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; if (r_LineNumber2 != 0) Tool.LineNumber = r_LineNumber2; Tool.DrawingType = DRAWING_MARKER; Tool.MarkerType = MARKER_X; Tool.Color = Color2.GetColor(); Tool.MarkerSize = 6; Tool.LineWidth = 3; Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.Low[sc.Index]; Tool.AddAsUserDrawnDrawing = 1; sc.UseTool(Tool); r_LineNumber2 = Tool.LineNumber;//Remember line number which has been automatically set } |
[2024-02-28 23:21:58] |
sampater - Posts: 244 |
4) Looks like Tool.Clear() does not reset Tool.Text. That seems like a bug to me. Adding Tool.Text.Clear() seems to resolve that and can be used till Sierra fixes this bug.
It also looks like a bug to me. The Tool.Text.Clear() solves the problem momentarily. |
[2024-03-01 01:04:33] |
Sierra_Chart Engineering - Posts: 17162 |
This will be resolved in the next release.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: