Login Page - Create Account

Support Board


Date/Time: Fri, 28 Mar 2025 13:12:26 +0000



[User Discussion] - hand-drawn horizontal tool

View Count: 623

[2022-11-26 03:03:20]
Ticks - Posts: 205
Does anyone have a study or code that can detect the last two hand-drawn horizontal tool lines and display their line value in a subgraph?
[2022-11-28 16:05:31]
User584084 - Posts: 268
Take a look at this. Try for 10 days for $1.

https://www.simplesystemtrading.com/trend-line-signal-study/
Date Time Of Last Edit: 2022-11-28 16:05:54
[2022-11-29 00:52:03]
Ticks - Posts: 205
Take a look at this. Try for 10 days for $1.

https://www.simplesystemtrading.com/trend-line-signal-study/

I already have tried that product.
It uses the ray tool, is not a breakout entry tool, and is a sealed product.

I need code that simply displays the hand-drawn horizontal tool line value in a subgraph that I can modify to fit my needs.

Or perhaps someone has study code that will draw a moveable horizontal line on a chart with its value displayed in a subgraph ??
Date Time Of Last Edit: 2022-11-29 01:34:48
[2022-11-29 15:15:33]
JohnR - User831573 - Posts: 322
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);
}

}

}
[2022-11-30 00:20:23]
Ticks - Posts: 205
Thanks JohnR.

This is a great start.
I will work on massaging the code to try and get what I need.
Thanks again.

If you can. Could you provide me the name of the forum you found this code block?
You can DM me directly if you prefer not to post the name here.
Date Time Of Last Edit: 2022-11-30 00:23:12
[2022-11-30 18:34:22]
JohnR - User831573 - Posts: 322
Ticks,

I thought I found it within a prior topic on this SC support Board. I just did some searches, but did not find a match. Sooo... I am not sure.

More age & less memory
JohnR
[2022-12-01 00:24:36]
Ticks - Posts: 205
Update.
The code draws a new line at the point of each left mouse click on the chart.
So the line is not really a move/adjustable line.
But it does place the line on the chart.

I will perhaps have to come up with an idea to have the line placed on the chart with perhaps a right mouse click only.Then have the ability to move the line up and down the chart with the normal left mouse button.

The good news is that I have been successful in modifying the code to get the line value to be displayed in a sub-graph.(see screen shots)
I changed the ray to a horizontal line in the code too.

So my main objective has been obtained, just need to work on the above mention issue.
Date Time Of Last Edit: 2022-12-01 10:19:16
imageHLine subgraph1.PNG / V - Attached On 2022-12-01 00:22:43 UTC - Size: 30.96 KB - 118 views
imageHLine subgraph2.PNG / V - Attached On 2022-12-01 00:22:51 UTC - Size: 48.29 KB - 102 views

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

Login

Login Page - Create Account