Login Page - Create Account

Support Board


Date/Time: Thu, 26 Dec 2024 13:32:40 +0000



Deleting all user drawn text drawings upon removing study

View Count: 1148

[2015-12-02 19:33:49]
KhaosTrader - Posts: 128
Hi,

I have a study that writes a lot of text drawings that need to be dynamically modified (which is why they are user drawings)... However, when I remove the study, I get remaining text drawings all over the place. I wrote this code , hoping it would delete them.. please advise on how I can make this work.

SC_TOOL_UniqueID is a persistent integer variable, that holds all the drawing IDs

  if (sc.Index == 0 || sc.LastCallToFunction)
  
  {
  
    for (int i = 0; i <= SC_TOOL_UniqueID; i++)
    
    sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, i);

  }

[2015-12-03 04:19:20]
Sierra Chart Engineering - Posts: 104368
The drawings do not need to be User Drawn unless you are modifying them from the user interface.

If the Chart Drawings are being programmatically modified, they do not have to be User Drawn.

Also we do not understand how a single integer variable could hold all of the Line Numbers. Debugging a problem like this is your responsibility. It is not possible for us to help with what we see. We do not know what the return value of the sc.DeleteUserDrawnACSDrawing() function is and what the Line Numbers were.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-12-03 06:10:39]
KhaosTrader - Posts: 128
Hi,

Thank you for your help, I will answer the two points:

1) I have the function that changes the text drawing color/hide the drawing.. If I dont make it a user drawn drawing, it doesn't work.

This is because I use the GetUserDrawingByLineNumber, where drawings need to be userdrawings.. if there is another method of retrieving the drawing by linenumber, without using a fuction that requires the drawing to be a userdrawing, please let me know...



bool ChangeTextDrawingColor(SCStudyGraphRef& sc, s_UseTool& Tool_TextWriter, int NumberText, bool HideAddonTextLabels)


{
Tool_TextWriter.AddMethod = UTAM_ADD_OR_ADJUST;
sc.GetUserDrawingByLineNumber(sc.ChartNumber, NumberText, Tool_TextWriter, DRAWING_TEXT, 0);
Tool_TextWriter.TransparentLabelBackground = 1;
if (HideAddonTextLabels == true)
{
  Tool_TextWriter.Text = "";

}
{
  Tool_TextWriter.TextColor = RGB(88, 88, 88);

}
Tool_TextWriter.TextColor = RGB(88,88,88);
sc.UseTool(Tool_TextWriter);

return true;
}


2. I need to keep track of these drawing line numbers to access them. I have more than one drawing per bar, hence I need to create a variable to hold them. I do this by creating a persistent integer and then use the following code




Tool_TextWriter.ChartNumber = ++SC_TOOL_UniqueID;


[2015-12-03 06:55:20]
KhaosTrader - Posts: 128
I did some reading, and found some instructions on modifying non user drawings, I set study to make all drawings to nonuserdrawings, and modified my function to this:


bool ChangeTextDrawingColor(SCStudyGraphRef& sc, s_UseTool& Tool_TextWriter, int NumberText, bool HideAddonTextLabels)


{
Tool_TextWriter.AddMethod = UTAM_ADD_OR_ADJUST;
//sc.GetUserDrawingByLineNumber(sc.ChartNumber, NumberText, Tool_TextWriter, DRAWING_TEXT, 0);

Tool_TextWriter.LineNumber = NumberText;
//Tool_TextWriter.TransparentLabelBackground = 1;
if (HideAddonTextLabels == true)
{
  //Tool_TextWriter.Text = "";

}

Tool_TextWriter.TextColor = RGB(88,88,88);
sc.UseTool(Tool_TextWriter);

return true;
}


The text drawings disappeared rather than have their color change. So it didn't work, and I am not sure why.

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

Login

Login Page - Create Account