Login Page - Create Account

Support Board


Date/Time: Mon, 31 Mar 2025 09:53:20 +0000



Post From: hand-drawn horizontal tool

[2022-11-29 15:15:33]
JohnR - User831573 - Posts: 325
Hope this helps
JohnR

To draw an object in a subgraph, just specify this property to the subgraph / region you want.
s_UseTool::Region
Type: integer
This is the region on the chart where the Chart Drawing appears. This number is 0 based and must be 0 to 12.
Region 0 represents Chart Region 1. This is where the Main Price Graph is located. Regions 1 to 11 correspond to chart regions 2 to 12. This is where the study graphs below the Main Price Graph are located.

Below is some code I found in the forums, I can not confirm it is good, but I'm pretty sure I compiled it to see what it did and it does create a Ray and then you can move it.

#include "sierrachart.h"

SCDLLName("Update Issue")

int CreateRay(SCStudyGraphRef sc, int i1, float p1, int i2, float p2)
{
s_UseTool tool;
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RAY;
tool.Region = sc.GraphRegion;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.TextAlignment = DT_RIGHT;
tool.BeginValue = p1;
tool.BeginIndex = i1;
tool.EndValue = p2;
tool.EndIndex = i2;
tool.Color = COLOR_GREEN;
tool.LineWidth = 2;
tool.LineStyle = LINESTYLE_SOLID;
tool.AddAsUserDrawnDrawing = 1;
sc.UseTool(tool);
return tool.LineNumber;
}



SCSFExport scsf_update_issue(SCStudyInterfaceRef sc)
{
int& line_num = sc.GetPersistentIntFast(1);
int& index1 = sc.GetPersistentIntFast(2);
if (sc.SetDefaults)
{
sc.GraphName = "Update Issue";
sc.StudyDescription = "";
sc.AutoLoop = 0;
sc.GraphRegion = 0;
sc.ReceivePointerEvents = ACS_RECEIVE_POINTER_EVENTS_ALWAYS;
return;
}


if (sc.UpdateStartIndex == 0)
{
if (line_num == 0)
{
index1 = sc.ArraySize - 10;
line_num = CreateRay(sc, index1, sc.Close[sc.ArraySize-2], index1 + 3, sc.Close[sc.ArraySize - 2]);
}
return;
}


if (sc.PointerEventType == SC_POINTER_BUTTON_DOWN)
{
s_UseTool chart_drawing;
if (sc.GetUserDrawnDrawingByLineNumber(sc.ChartNumber, line_num, chart_drawing))
{
chart_drawing.BeginDateTime.Clear();
chart_drawing.EndDateTime.Clear();
chart_drawing.BeginIndex = sc.ActiveToolIndex;
chart_drawing.BeginValue = sc.ActiveToolYValue;
chart_drawing.EndIndex = sc.ActiveToolIndex + 1;
chart_drawing.EndValue = sc.ActiveToolYValue;
sc.UseTool(chart_drawing);
}

}

}