Login Page - Create Account

Support Board


Date/Time: Thu, 13 Feb 2025 19:10:22 +0000



Post From: ACSIL issue with writing drawings to remote chart

[2020-12-14 18:02:22]
onnb - Posts: 662
Thanks for taking a look - I tested your script and it works fine.
I checked for the differences and looks like the issue comes up with AutoLoop = 1;

I modified your script slightly to support AutoLooping and tested
Pasting here for your reference. Using this I can reproduce it on 2204.


SCSFExport scsf_UseToolExampleRectangleHighlight(SCStudyInterfaceRef sc)
{
  SCInputRef in_remote_chart = sc.Input[0];
  // Draw a rectangle highlight

  // Set configuration variables
  if (sc.SetDefaults)
  {
    sc.GraphName = "UseTool Example: Rectangle Highlight AutoLoop";
    sc.GraphRegion = 0;

    sc.AutoLoop = 1; //No automatic looping

    in_remote_chart.Name = "Remote Chart Number";
    in_remote_chart.SetInt(0);

    return;
  }

  if (sc.LastCallToFunction)
    return;

  int& r_LineNumber = sc.GetPersistentInt(1);
  int& r_ChartNumber = sc.GetPersistentInt(2);

  if (sc.Index == 0)
  {
    if (r_LineNumber != 0)
    {
      sc.DeleteUserDrawnACSDrawing(r_ChartNumber, r_LineNumber);
      r_LineNumber = 0;
    }
  }

  if (sc.Index < sc.ArraySize - 3)
    return;

  // Do data processing
  int BarIndex = 0;

  s_UseTool Tool;

  //Tool.ChartNumber = sc.ChartNumber;
  Tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;

  if (r_LineNumber != 0)
    Tool.LineNumber = r_LineNumber;

  // Update BarIndex to 30 bars from the end
  BarIndex = max(sc.ArraySize - 25, 0);
  Tool.BeginDateTime = sc.BaseDateTimeIn[BarIndex];
  BarIndex = max(sc.ArraySize - 15, 0);
  Tool.EndDateTime = sc.BaseDateTimeIn[BarIndex];
  Tool.BeginValue = sc.GetHighest(sc.Low, BarIndex, 10);
  Tool.EndValue = sc.GetLowest(sc.Low, BarIndex, 10);
  Tool.Color = RGB(255, 0, 0); // Red
  Tool.LineWidth = 1; //To see the outline this must be 1 or greater.
  Tool.SecondaryColor = RGB(0, 255, 0);
  Tool.TransparencyLevel = 50;
  Tool.AddMethod = UTAM_ADD_OR_ADJUST;

  // Add rectangle drawing to chart number 2.
  Tool.AddAsUserDrawnDrawing = 1;
  Tool.ChartNumber = in_remote_chart.GetInt();
  r_ChartNumber = Tool.ChartNumber;

  sc.UseTool(Tool);

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