Login Page - Create Account

Support Board


Date/Time: Fri, 27 Dec 2024 00:51:29 +0000



ACSIL: UseTool

View Count: 1562

[2016-03-21 16:53:36]
User53601 - Posts: 105
Hello,

In some price configurations I display some text via UseTool.
Having the text drawing tool displayed by the study, usually I could move the text manually throught the chart.

For some reason, I can not move it any more. The drawing text is fixed on the chart and I cannt move it manually away, to other place on the chart.
I don’t guess what has changed, or if I changed unintentionaly some setting.

Can you advise where could be the reason.


Here is the code part of the code:

s_UseTool LineTradeCode;
LineTradeCode.Clear();        
LineTradeCode.DrawingType = DRAWING_TEXT;  

LineTradeCode.AddMethod = UTAM_ADD_OR_ADJUST;
LineTradeCode.AddAsUserDrawnDrawing = 1;


Thank you
[2016-03-22 09:01:04]
Sierra Chart Engineering - Posts: 104368
Here is a code example we put together and tested to work:


SCSFExport scsf_UseToolExampleText(SCStudyInterfaceRef sc)
{
  // Set configuration variables
  if (sc.SetDefaults)
  {
    sc.GraphName = "UseTool Example: Text";
    sc.StudyDescription = "User drawn text drawing example.";

    sc.GraphRegion = 0;
    sc.FreeDLL = 0;
    sc.AutoLoop = 0; //No automatic looping

    return;
  }


  int &TextDrawingLineNumber = sc.GetPersistentInt(1);

  if (TextDrawingLineNumber != 0 && sc.LastCallToFunction)
  {
    // Be sure to remove the Text drawing added as a user drawn drawing
    sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, TextDrawingLineNumber);
    return;//No further processing needed in this case.
  }

  // Do data processing  
  int BarIndex = sc.ArraySize - 20;

  if (BarIndex < 0)
    return;

  s_UseTool TextDrawing;
  TextDrawing.Clear();//Not necessary but good practice
  TextDrawing.ChartNumber = sc.ChartNumber;
  TextDrawing.DrawingType = DRAWING_TEXT;
  
  if(TextDrawingLineNumber != 0)
    TextDrawing.LineNumber = TextDrawingLineNumber;
  
  TextDrawing.AddAsUserDrawnDrawing = 1;
  
  TextDrawing.BeginIndex = BarIndex;
  TextDrawing.BeginValue = sc.High[BarIndex];
  TextDrawing.Color = COLOR_KHAKI;
  TextDrawing.Text = "Movable User Drawn Text Example";
  TextDrawing.FontSize = 18;
  // do not keep adjusting
  TextDrawing.AddMethod = UTAM_ADD_ONLY_IF_NEW;

  sc.UseTool(TextDrawing);

  //Remember the line number which has been automatically assigned
  TextDrawingLineNumber = TextDrawing.LineNumber;
}

To move the text drawing make sure a non-drawing tool is selected like Tools >> Pointer.

Make sure you also have not locked the drawing.
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
Date Time Of Last Edit: 2016-03-22 09:03:29
[2016-03-25 18:53:37]
User53601 - Posts: 105
Thank you for the code, I used it for testing, and it brought me to the solution.

I have more of my own studies on the chart.
The source of the problem was in one of them.

In one of the study I deleted user drawing without prior testing whether the drawing exists.


By replacing sc.DeleteUserDrawnACSDrawing

with

if sc.ChartDrawingExists then sc.DeleteUserDrawnACSDrawing


the problem dissapperaed.
I did not guess two studies in one chart could be interconnected in such a way.

thank you again for the support.
Date Time Of Last Edit: 2016-03-25 18:56:22

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

Login

Login Page - Create Account