Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 11:45:22 +0000



Post From: sc.UseTool and Line not drawing properly with 1-150 X axis values

[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