Login Page - Create Account

Support Board


Date/Time: Mon, 16 Sep 2024 07:15:47 +0000



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

[2013-07-23 07:58:16]
Kiwi - Posts: 375
Scrap the last post ...

Just took your original code again and set i1 = 0

Thats the problem. Your value of i1 changed each time you changed the seconds per bar. As a result your delete command didn't work.

Working code is:

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
i1 = 0 // set it to a constant for testing
  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);
}
}