Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 12:42:11 +0000



[Programming Help] - sc.UseTool and Line not drawing properly with 1-150 X axis values

View Count: 271

[2024-08-31 17:26:01]
User719512 - Posts: 262
See attached images.
with 75 as anchor 2 of line properties, line ends at 50% or halfway of the window.
with 150 as anchor 2 of line properties, line extends only to last bar and not the right side of the window.

The real use case here is to use sc.UseTool for Tool.DrawingType = DRAWING_LINE; to accomplish the same thing (line all the way across).
When drawn from code, the same behavior is observed.

Please advise, thanks.
imageScreenshot 2024-08-31 101147.png / V - Attached On 2024-08-31 17:25:03 UTC - Size: 83.29 KB - 51 views
imageScreenshot 2024-08-31 101214.png / V - Attached On 2024-08-31 17:25:13 UTC - Size: 84.66 KB - 49 views
[2024-08-31 17:55:42]
DarkNature - Posts: 1
From my observation that happens only if UseRelativeVerticalValues is disabled. By setting it to 1 the anchor of 150 goes to the end of the chart.
But unfortunately I believe that makes it not possible to draw a line at absolute values like a price and use relative horizontal values at the same time properly.
Thanks in advance for your support.
[2024-08-31 17:59:33]
seandunaway - Posts: 268
the docs have a note about drawing into the fill space with EndDateTime or EndIndex
Using Drawing Tools From an Advanced Custom Study: s_UseTool::EndDateTime
[2024-08-31 18:05:27]
seandunaway - Posts: 268
you might also try a different drawing type if you're just looking for a full width price level or similar
Using Drawing Tools From an Advanced Custom Study: s_UseTool::DrawingType
Date Time Of Last Edit: 2024-08-31 18:06:41
[2024-08-31 18:26:32]
User431178 - Posts: 540
the docs have a note about drawing into the fill space with EndDateTime or EndIndex

They do, but that is not relevant if you are using relative positioning. The purpose being to position drawings in fixed location via coordinate system, not tied to a bar index or real datetime.


Seems something is broken.
Or maybe some drawing tools don't play nice with relative positioning?
Date Time Of Last Edit: 2024-08-31 18:29:23
[2024-08-31 22:57:39]
Sierra_Chart Engineering - Posts: 17145
We do not see any problem with this. There definitely is nothing in the code, which positions, a Chart Drawing with consideration to coordinates of chart bars, when using relative horizontal positioning (0 to 150), and there is also a high-resolution version of this, available. Positioning is relative to the Chart Region itself. Here is an example of the Symbol Display:
https://www.sierrachart.com/image.php?Image=1725144997418.png

Make sure you are running an up-to-date version of Sierra Chart.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2024-09-01 04:14:55
[2024-09-01 00:47:08]
User719512 - Posts: 262
Huh? You posted a reply with text, not a line. Question was about making a line extend to end of the chart not just the last bar.
[2024-09-01 00:57:30]
seandunaway - Posts: 268
i think the issue is you're trying to combine absolute y with relative x, which doesn't seem possible
Date Time Of Last Edit: 2024-09-01 02:11:22
[2024-09-01 02:06:26]
seandunaway - Posts: 268
using the previously linked EndIndex or extended DrawingType does what you want, i think..

#include "sierrachart.h"

SCDLLName("fill space line")

SCSFExport scsf_fill_space_line(SCStudyInterfaceRef sc) {
  if (sc.SetDefaults) {
    sc.AutoLoop = 0;
    sc.DisplayStudyName = 0;
    sc.GraphName = "fill space line";
    sc.GraphRegion = 0;
    sc.UpdateAlways = 1;
    return;
  }

  double last_price = sc.GetLastPriceForTrading();
  double price_begin = last_price - (last_price * 0.0025);
  double price_end = last_price + (last_price * 0.0025);

  s_UseTool tool;
  tool.Clear();
  tool.AddMethod = UTAM_ADD_OR_ADJUST;
  tool.BeginIndex = sc.IndexOfFirstVisibleBar;
  tool.BeginValue = (float) price_begin;
  tool.Color = 0xff0080;
  tool.DrawingType = DRAWING_LINE;
  tool.EndIndex = sc.IndexOfLastVisibleBar + (int) sc.NumFillSpaceBars;
  tool.EndValue = (float) price_end;
  tool.LineWidth = 10;

  int& line = sc.GetPersistentIntFast(0);
  if (line != 0) tool.LineNumber = line;
  sc.UseTool(tool);
  line = tool.LineNumber;
}

Date Time Of Last Edit: 2024-09-01 02:15:45
imagefill_space_line.png / V - Attached On 2024-09-01 02:06:22 UTC - Size: 126.77 KB - 49 views

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

Login

Login Page - Create Account