Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 05:13:17 +0000



Setting drawing LineNumber to price in ticks, then erasing if price met

View Count: 795

[2016-09-28 06:34:18]
binaryduke - Posts: 360
Hi SierraChart

I'm stuck on a simple problem and would appreciate a quick steer in the correct direction.

I wish to draw a marker at a price level, then erase it if the price trades again.

I am setting the LineNumber of the marker to the price - an int which should be the price in ticks - I'm not multiplying by sc.TickSize.

The code to draw the marker works fine.

Each time the routine is called, I call:
sc.DeleteACSChartDrawing (0, TOOL_DELETE_CHARTDRAWING, sc.LastTradePrice);

I would presume that if no drawing exists with a LineNumber of sc.LastTradePrice there's no harm done, however, the previously drawn markers do not erase. From this I presume the LineNumber is not set to what I'm expecting.

I'd appreciate a steer as to what I'm missing.

Many thanks

Lee.
[2016-09-28 19:16:42]
Sierra Chart Engineering - Posts: 104368
Here is a code example:


SCSFExport scsf_DeleteACSChartDrawingExample(SCStudyInterfaceRef sc)
{
  // Set configuration variables
  if (sc.SetDefaults)
  {
    sc.GraphName = "Delete ACS Chart Drawing Example";
    sc.StudyDescription = "";

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

    return;
  }

  int& LineNumber = sc.GetPersistentInt(1);

  //Only do processing on the last bar
  if (sc.IsFullRecalculation)
  {
    //Set the previously remembered line number to 0 because on a full recalculation advanced custom study drawings are automatically deleted
    LineNumber = 0;
    return;
  }



  if(LineNumber != 0)
  {
    int Result = sc.DeleteACSChartDrawing(sc.ChartNumber,TOOL_DELETE_CHARTDRAWING, LineNumber);
    LineNumber = 0;
  }

  s_UseTool Tool;

  Tool.ChartNumber = sc.ChartNumber;
  //Tool.LineNumber will be automatically set. No need to set this.
  Tool.DrawingType = DRAWING_MARKER;
  Tool.BeginIndex = sc.ArraySize - 1;

  Tool.MarkerType = MARKER_ARROWUP;
  Tool.BeginValue = sc.Low[sc.ArraySize - 1];


  Tool.Region = 0;
  Tool.Color = RGB(0, 255, 0);
  Tool.MarkerSize = 8;
  Tool.LineWidth = 4;
  Tool.AddMethod = UTAM_ADD_ALWAYS;

  sc.UseTool(Tool); // Here we make the function call to add the marker

  //Remember the line number so it can be deleted at the beginning of the function when set
  LineNumber = Tool.LineNumber;

}

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

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

Login

Login Page - Create Account