Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 00:35:02 +0000



Post From: Prevent UserDrawnDrawings to be copied when chart is duplicated

[2021-07-29 16:20:39]
@sstfrederik - Posts: 403
Hi John,

That is not what I meant. The Tool.AllowCopyToOtherCharts = 0; is the default, is a different functionality, and this does not prevent a drawing to be duplicated when a chart is duplicated.

When example study is loaded on a chart. And this chart is subsequently duplicated, you will see two rectangle highlight drawings are being drawn on that new chart. One is from the duplication and another one from the study calculation.

Would be great if this can be prevented and only the one from the study to be drawn.

Thanks for your time.

Frederik

Example code:

SCSFExport scsf_UseToolExampleRectangleHighlight(SCStudyInterfaceRef sc)
{
  // Draw a rectangle highlight

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

    return;
  }

  int& r_LineNumber = sc.GetPersistentInt(1);
  
  if (sc.LastCallToFunction){
    
    
    if (sc.UserDrawnChartDrawingExists(sc.ChartNumber,r_LineNumber) > 0){
      
      sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, r_LineNumber);
    }
    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;
  Tool.AllowSaveToChartbook = 0;
  Tool.AddAsUserDrawnDrawing = 1;
  Tool.AllowCopyToOtherCharts = 0;
  
  sc.UseTool(Tool);

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