Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 07:21:29 +0000



Post From: ACSIL - how to delete (ACSIL) user drawings when time frame is changed?

[2013-07-22 08:10:22]
User11748 - Posts: 14
I have prepared (below) a minimal 40-line code in order to better show the issue I am reporting.
This code draws a marker (ACSIL user drawing) 10 bars before the 1st bar of July 19th, 2013.
When timeframe is changed, new marker appears, but old ones stay on the chart. How to programmatically delete them?
The issue is illustrated on the attached picture, with comments embedded.

#include "sierrachart.h"

SCDLLName("Nicolas Test 2");

SCSFExport scsf_Nicolas_Test_2(SCStudyGraphRef sc) {

  if ( sc.SetDefaults ) {
    sc.GraphName = "Nicolas Test 2";
    sc.AutoLoop = 1;
    sc.FreeDLL = 1;
    sc.GraphRegion = 0;
    return;
  }

  int UniqueLineNumber = 74191;

  if ( sc.LastCallToFunction && sc.PersistVars->i1 > 0 ) {
    sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, UniqueLineNumber + sc.PersistVars->i1);
  }

  bool firstBarOfJuly_19_2003 = sc.BaseDateTimeIn[sc.Index].GetYear() == 2013
    && sc.BaseDateTimeIn[sc.Index].GetMonth() == 7
    && sc.BaseDateTimeIn[sc.Index].GetDay() == 19
    && sc.BaseDateTimeIn[sc.Index-1].GetDay() != 19;

  if ( firstBarOfJuly_19_2003 ) {
    sc.PersistVars->i1 = sc.Index - 10; // index of the bar on top of which the marker shall be drawn
    s_UseTool Tool;
    Tool.Clear();
    Tool.ChartNumber = sc.ChartNumber;
    Tool.DrawingType = DRAWING_MARKER;
    Tool.LineNumber = UniqueLineNumber + sc.PersistVars->i1;
    Tool.BeginIndex = sc.PersistVars->i1;
    Tool.BeginValue = sc.High[sc.PersistVars->i1];
    Tool.Color = RGB(0,200,200);
    Tool.AddMethod = UTAM_ADD_ALWAYS;
    Tool.MarkerType = MARKER_X;
    Tool.MarkerSize = 8;
    Tool.LineWidth = 5;
    Tool.AddAsUserDrawnDrawing = 1; // ***
    sc.UseTool(Tool);
  }
}

Date Time Of Last Edit: 2013-07-22 08:15:01
image2013-07-22_SC.png / V - Attached On 2013-07-22 08:13:56 UTC - Size: 264.14 KB - 730 views