Login Page - Create Account

Support Board


Date/Time: Thu, 12 Jun 2025 08:04:43 +0000



[Programming Help] - Unable to reset line after sc.DeleteUserDrawnACSDrawing using s_UseTool Tool

View Count: 513

[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.
[2022-11-09 09:08:59]
User92573 - Posts: 563
Partially solved.

I have the line repainting but it doesn't always get deleted? So, still not acting as expected and I'm a little confused.

Here is the tool "Horizontal Line" clear function.


if (sc.MenuEventID == Button_2)
{
  if (sc.PointerEventType == SC_ACS_BUTTON_ON)
  {
    
  s_UseTool ChartDrawing;
        
    // begin accepting mouse events

    sc.SetCustomStudyControlBarButtonEnable(Button_2, 1);
    
    sc.GetUserDrawnDrawingByLineNumber(0, r_LineNumber_Test_RefLine, ChartDrawing);
    sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, r_LineNumber_Test_RefLine);

    r_LineNumber_Test_RefLine= 0; // I'm now resetting the PersVar but I don't see why?    

    sc.SetCustomStudyControlBarButtonEnable(Button_19, 0);      

  }
  
  else if (sc.PointerEventType == SC_ACS_BUTTON_OFF)
  {
    sc.SetCustomStudyControlBarButtonEnable(Button_2, 0);        
  }      

}

If I reset the line number to 0, so that Sierra generates a new unique number when Button_1 is used to draw
a new line again using the same price value:

Tool.BeginValue = Price_Level_1

Then I felt all should work as intended but that's not the case?

Do I even need to reset the “r_LineNumber_Test_RefLine= 0;  ” because I can't see why it would be necessary as either the new or old exist in the PersVar.

Obviously getting a little confused. Certainly, allowing Sierra to generate another unique number solves it 'sometimes' but it's inconsistent?

Any help appreciated.
Date Time Of Last Edit: 2022-11-09 10:36:28

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account