Login Page - Create Account

Support Board


Date/Time: Fri, 13 Jun 2025 08:32:07 +0000



Post From: Unable to reset line after sc.DeleteUserDrawnACSDrawing using s_UseTool Tool

[2022-11-08 14:47:39]
User92573 - Posts: 563
Dear Support

I'd be very grateful for some assistance with the following.

I have for example 2 ACS Button Events that run as follows:

Button_1 Populates a Persistent Variable "Price_Level_1" that is used to draw a simple Horizontal Line.


if(Price_Level_1 != 0)
{
s_UseTool Tool;

  Tool.ChartNumber = sc.ChartNumber;
  Tool.DrawingType = DRAWING_HORIZONTALLINE;

  Tool.AddMethod = UTAM_ADD_OR_ADJUST;
  Tool.AddAsUserDrawnDrawing = 1;
  Tool.AllowSaveToChartbook = 1;        
  
  if r_LineNumber_Test_RefLine;!= 0)
    Tool.LineNumber = r_LineNumber_Test_RefLine;
  
  Tool.BeginValue = Price_Level_1;  
  
  Tool.Color = RGB(0, 0, 0);
  Tool.LineWidth = 1; // LineWidth must be 1 to use non-solid line styles
  Tool.LineStyle = LINESTYLE_DOT;
  Tool.Text = "Test.";
  Tool.ShowPrice = 1;
  Tool.RoundToTickSize = 1;
  Tool.TextAlignment = DT_VCENTER | DT_RIGHT;  
  Tool.TransparentLabelBackground = 1;

  sc.UseTool(Tool);

  r_LineNumber_Test_RefLine = Tool.LineNumber; //Remember line number which has been automatically set
}      

This correctly places the anticipated line on the chart at "Price_Level_1".

Testing the PersVars I can see that they hold the following example values:


Price_Level_1 = "Correct price value"
r_LineNumber_Test_RefLine = "-56789"


Button_2 uses the following function to delete the line:


sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, r_LineNumber_Test_RefLine);

As expected, this removed line while the PersVars were retained:




-------------------------------------------------------
So, here is my issue
-------------------------------------------------------

Select Button_1 again.

Here I want to return/recover the Horizontal line to the chart using the same "Price_Level_1".


Price_Level_1 = "Correct price value"
r_LineNumber_Test_RefLine = "-56789" which is the same number as was set earlier.


if(Price_Level_1 != 0)
{
s_UseTool Tool;

  Tool.ChartNumber = sc.ChartNumber;
  Tool.DrawingType = DRAWING_HORIZONTALLINE;

  Tool.AddMethod = UTAM_ADD_OR_ADJUST;
  Tool.AddAsUserDrawnDrawing = 1;
  Tool.AllowSaveToChartbook = 1;        
  
  if r_LineNumber_Test_RefLine;!= 0)
    Tool.LineNumber = r_LineNumber_Test_RefLine;
  
  Tool.BeginValue = Price_Level_1;  
  
  Tool.Color = RGB(0, 0, 0);
  Tool.LineWidth = 1; // LineWidth must be 1 to use non-solid line styles
  Tool.LineStyle = LINESTYLE_DOT;
  Tool.Text = "Test.";
  Tool.ShowPrice = 1;
  Tool.RoundToTickSize = 1;
  Tool.TextAlignment = DT_VCENTER | DT_RIGHT;  
  Tool.TransparentLabelBackground = 1;

  sc.UseTool(Tool);

  r_LineNumber_Test_RefLine = Tool.LineNumber; //Remember line number which has been automatically set
}      

... But no line is drawn?

Have I missed something as can't see I need increment the LineNumber and I've read through the relevant information?

Many thanks.