Login Page - Create Account

Support Board


Date/Time: Tue, 25 Feb 2025 23:31:03 +0000



[Programming Help] - Cannot get Price Labels on DRAWING_RECTANGLE_EXT_HIGHLIGHT

View Count: 661

[2021-05-03 06:28:53]
User719512 - Posts: 299
Hello,
I cannot seem to get Price Labels on DRAWING_RECTANGLE_EXT_HIGHLIGHT drawings. Best as I can tell, my code matches what the UI would show if I drew the same rectangle manually. Below is some sample code that draws a rectangle, but is missing price labels for the BeginValue and EndValue inputs.

Any idea why?

Thanks,
Kory


#include "sierrachart.h"
SCDLLName("kg_Kory_Sandbox")


int AddRectangleHighlight(SCStudyInterfaceRef sc, float beginValue, float endValue, int index, COLORREF PrimaryColor, COLORREF SecondaryColor, int width)
{
  // Draw a rectangle highlight
  int lineNumber = 0;

  s_UseTool Tool;

Tool.Clear();
  Tool.ChartNumber = sc.ChartNumber;
Tool.Region = sc.GraphRegion;
  Tool.DrawingType = DRAWING_RECTANGLE_EXT_HIGHLIGHT;  
  //Tool.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;  
  Tool.BeginIndex = index;
  Tool.EndIndex = index+0;
  Tool.BeginValue = beginValue;
  Tool.EndValue = endValue;
  Tool.Color = PrimaryColor;
  Tool.LineWidth = width; // To see the outline this must be 1 or greater.
  Tool.SecondaryColor = SecondaryColor;
  Tool.TransparencyLevel = 80;
  //Tool.AddMethod = UTAM_ADD_ALWAYS;
  Tool.LineNumber = 0xDEADBEEF;
Tool.AddMethod = UTAM_ADD_OR_ADJUST;
  Tool.TextAlignment = DT_RIGHT;

  //
  // WHY DOESN'T THIS SHOW LABELS??????
  //
  Tool.ShowLabelsAtEnd = 1;
  Tool.ShowLabels = 1;
  Tool.CenterPriceLabels = 1;

  Tool.AddAsUserDrawnDrawing = 0;
  int ret = sc.UseTool(Tool);

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

return lineNumber;
}


// ===========================================================================
// kg_Kory_Sandbox
// ===========================================================================
SCSFExport scsf_kg_Kory_Sandbox(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "kg_Kory_Sandbox";
sc.AutoLoop = 1;
    sc.DrawZeros = 0;
sc.GraphRegion = 0;
sc.DrawStudyUnderneathMainPriceGraph = 0;


return;
}


  if (sc.Index == sc.ArraySize - 100 && sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED) {
    AddRectangleHighlight(sc, sc.High[sc.Index]+10, sc.Low[sc.Index]-10, sc.Index, RGB(210,210,0), RGB(0,210,210), 1);
  }
}
[2021-05-03 12:37:15]
User907968 - Posts: 833
Try using 'ShowPrice' - Using Drawing Tools From an Advanced Custom Study: s_UseTool::ShowPrice
[2021-05-03 16:49:44]
User719512 - Posts: 299
Thank you for that. I try really hard to investigate and research things before asking questions, and not sure how I missed this, but that was exactly it.

THANK YOU.

I am glad this was something trivial, and I just missed that.
Date Time Of Last Edit: 2021-05-03 21:45:25

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

Login

Login Page - Create Account