Login Page - Create Account

Support Board


Date/Time: Fri, 28 Mar 2025 17:36:02 +0000



Post From: Docs incorrect - cause a compile error.

[2022-11-09 16:16:22]
JohnR - User831573 - Posts: 323
Using Drawing Tools From an Advanced Custom Study: s_UseTool::DrawingType

s_UseTool::LineStyle
Type: Integer

The line style for the chart drawing. Available line styles are: LINESTYLE_SOLID, LINESTYLE_DASH, LINESTYLE_DOT, LINESTYLE_DASHDOT, and LINESTYLE_DASHDOTDOT.


When I try to use an int variable to set the tool.LineStyle the compiler throws an error.
1>F:\- John's Personal Stock stuff\Sierra Chart Stuff\JOR_Custom_Studies\JOR_Custom_Studies_Collection\JOR_Custom_Studies_Collection.cpp(2806,49): error C2440: '=': cannot convert from 'int' to 'SubgraphLineStyles'
1>F:\- John's Personal Stock stuff\Sierra Chart Stuff\JOR_Custom_Studies\JOR_Custom_Studies_Collection\JOR_Custom_Studies_Collection.cpp(2806,48): message : Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast)

even using the drawing object structure I just read and getting the JOR_DrawingObj.LevelStyle[x] throws an error

Only using your enumerations will compile.

DGL_Tool.LineStyle = JOR_LevelStyle[looper];
DGL_Tool.LineStyle = JOR_DrawingObj.LevelStyle[looper];
DGL_Tool.LineStyle = LINESTYLE_SOLID;

definitions above error code
// Set or reset variables used to hold properties of pitchfork
  float JOR_Levels[32] = { FLT_MAX };
  COLORREF JOR_LevelColor[32] = { 0 };
  int JOR_LevelWidth[32] = { 0 };
  int JOR_LevelStyle[32] = { 0 };

  // Get values from drawing object instance
for (int looper = 0; looper < 32; looper++)
  {
  JOR_Levels[looper] = JOR_DrawingObj.RetracementLevels[looper];
  JOR_LevelColor[looper] = JOR_DrawingObj.LevelColor[looper];
  JOR_LevelWidth[looper] = JOR_DrawingObj.LevelWidth[looper];
  JOR_LevelStyle[looper] = JOR_DrawingObj.LevelStyle[looper];

Guidance please
JohnR

Update - I also took a stab a making it an explicit static cast. The compile gave different errors.

SubgraphLineStyles DGL_Tool.LineStyle = static_cast<SubgraphLineStyles>(JOR_LevelStyle[looper]);

Update 2 - I am able to compile - I corrected the static cast line
DGL_Tool.LineStyle = static_cast<SubgraphLineStyles>(JOR_LevelStyle[looper]);
Date Time Of Last Edit: 2022-11-09 16:24:48