Login Page - Create Account

Support Board


Date/Time: Tue, 13 May 2025 18:01:39 +0000



Post From: Problems adjusting ChartDrawing that was added as User Drawn Drawing

[2024-08-29 14:50:01]
Sierra_Chart Engineering - Posts: 19573
We cannot spend the time debugging your code but we did some testing and modification of an existing function we have to work with user drawn chart drawings and it works properly:

SCSFExport scsf_UseToolExampleDrawingLine(SCStudyInterfaceRef sc)
{
  // Set configuration variables
  if (sc.SetDefaults)
  {
    sc.GraphName = "UseTool Example: Line";
    sc.GraphRegion = 0;
    
    sc.AutoLoop = 0; //No automatic looping

    return;
  }

  int& r_LineNumber = sc.GetPersistentInt(1);

  if (sc.IsFullRecalculation)
  {
    //Draw vertical line on prior bar during full recalculation.
    s_UseTool Tool;
    Tool.Clear();
    Tool.ChartNumber = sc.ChartNumber;
    //Tool.LineNumber will be automatically set. No need to set this.
    Tool.DrawingType = DRAWING_LINE;
    int DrawingIndex = sc.ArraySize - 1;
    Tool.BeginDateTime = sc.BaseDateTimeIn[DrawingIndex - 20];
    Tool.EndDateTime = sc.BaseDateTimeIn[DrawingIndex];
    Tool.BeginValue = sc.Low[DrawingIndex - 20];
    Tool.EndValue = sc.High[DrawingIndex];
    Tool.Text = "Label 1";
    Tool.TextAlignment = DT_BOTTOM | DT_RIGHT;
    Tool.Region = 0;
    Tool.Color = RGB(255, 255, 0);
    Tool.LineWidth = 5;
    Tool.AddMethod = UTAM_ADD_ALWAYS;
    Tool.AddAsUserDrawnDrawing = 1;

    sc.UseTool(Tool);
    r_LineNumber = Tool.LineNumber;
  }
  else if (sc.UpdateStartIndex < sc.ArraySize -1)//Do this when a new bar is added
  {
    //Now move the drawing to the last bar when a new bar has been added to the chart
    s_UseTool Tool;
    Tool.Clear();
    Tool.DrawingType = DRAWING_LINE;
    Tool.ChartNumber = sc.ChartNumber;
    int DrawingIndex = sc.ArraySize - 1;
    Tool.BeginDateTime = sc.BaseDateTimeIn[DrawingIndex - 30];
    Tool.EndDateTime = sc.BaseDateTimeIn[DrawingIndex];
    Tool.BeginValue = sc.Low[DrawingIndex - 30];
    Tool.EndValue = sc.High[DrawingIndex];
    Tool.Region = 0;
    Tool.Color = RGB(255, 0, 0);
    Tool.LineWidth = 20;
    Tool.AddMethod = UTAM_ADD_OR_ADJUST;

    s_UseTool ExistingDrawing;
    int Result = sc.GetUserDrawnDrawingByLineNumber(sc.ChartNumber, r_LineNumber, ExistingDrawing);

    if (Result == 0)
      r_LineNumber = 0;

    Tool.LineNumber = r_LineNumber;

    Tool.AddAsUserDrawnDrawing = 1;
    sc.UseTool(Tool);
    
    r_LineNumber = Tool.LineNumber;
  }

  //int Count = sc.DeleteACSChartDrawing(sc.ChartNumber, TOOL_DELETE_ALL, 0);
}

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
Date Time Of Last Edit: 2024-11-29 01:40:38