Login Page - Create Account

Support Board


Date/Time: Sun, 28 Apr 2024 10:12:49 +0000



[Programming Help] - Help - can't get my ACSIL code to draw Horizontal line

View Count: 1363

[2020-04-26 18:49:09]
JohnR - User831573 - Posts: 300
I have debugger the following code. Stepping through it with no errors. I do see values being assigned to the various parts of the structure. Just as a "skeleton test" I also see indicator values plotted correctly in 1st subchart. B u t --- no Horizontal line. I have tried it both ways, assigning a value to Tool.LineNumber and commenting that line of code out.

// The top of every source code file must include this line
#include "sierrachart.h"

// This line is required. Change the text within the quote
// marks to what you want to name your group of custom studies.

SCDLLName("JOR_Skeleton_Template")

//This is the basic framework of a study function.

/*============================================================================
  This is a template function I use to test out a new functionaility by
  itself before trynig to add it to a more complete study
----------------------------------------------------------------------------*/

SCSFExport scsf_JOR_Skeleton(SCStudyGraphRef sc)
{

  // Set the configuration variables

  SCInputRef In_JOR_Buy_Line = sc.Input[0];

  // Set Names for persisten variables and type
  
  int& JOR_Test_Var = sc.GetPersistentInt(1);

  if (sc.SetDefaults)
  {
    sc.GraphName = "JOR Skeleton Template";
    sc.StudyDescription = "I use this as a test skeleton to learn how various things work.";

    sc.Input[0].Name = "In_JOR_Buy_Line";
    sc.Input[0].SetFloat(25.0f); // Set the default value to 20
    sc.Input[0].SetFloatLimits(5.0f, 99.0f); //Optional: Limit the range of this input to 1-1000

    sc.AutoLoop = 1; // true

    // During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance.
    sc.FreeDLL = 1;

    sc.Subgraph[0].Name = "JOR_Skeleton";

    return;
  }

  // Data processing

  // On Index/Bar 1 draw a horizontal line

  if (sc.Index == 1) // I initially tried to use sc.Index == 0

  {
    // Use Drawing tool -> Horizontal line for Buy-Sell-50 Lines
    s_UseTool Tool;

    // Draw Buy Level horz line

    // Reset tool structure. It insures the structure you are about to use / fill, stats out blank with no left over data.
    Tool.Clear();

    Tool.ChartNumber = sc.ChartNumber;
    Tool.DrawingType = DRAWING_HORIZONTALLINE;
//    Tool.LineNumber = int(In_JOR_Buy_Line.GetFloat());
    Tool.BeginValue = In_JOR_Buy_Line.GetFloat();
    Tool.LineWidth = 1;
    Tool.LineStyle = LINESTYLE_DASH;
    Tool.Color = RGB(17, 255, 57);
    Tool.AddMethod = UTAM_ADD_OR_ADJUST;
    sc.UseTool(Tool);
  }

  if (sc.Index == 0) JOR_Test_Var = 1;
  if (JOR_Test_Var > 99) JOR_Test_Var = 1;

  // Just plotting a value between 1 and 99 to see that the code is executing
  sc.Subgraph[0][sc.Index] = float(JOR_Test_Var);
  JOR_Test_Var++;
}
Date Time Of Last Edit: 2020-04-26 21:07:50
[2020-04-27 01:34:09]
Flipper - Posts: 65
Hi

You have set the region you want it drawn to.

Using Drawing Tools From an Advanced Custom Study: s_UseTool::Region

so if you want to set the region you have the study on.


Tool.Clear();
Tool.ChartNumber = sc.ChartNumber;
Tool.DrawingType = DRAWING_HORIZONTALLINE;
Tool.BeginValue = In_JOR_Buy_Line.GetFloat();
Tool.LineWidth = 1;
Tool.Region = sc.GraphRegion; /// <<<<<<<<<<<<<<< This will draw to the same region as the study is applied to
Tool.LineStyle = LINESTYLE_DASH;
Tool.Color = RGB(17, 255, 57);
Tool.AddMethod = UTAM_ADD_OR_ADJUST;

else its Tool.Region = 0 to always draw on main price graph
Date Time Of Last Edit: 2020-04-27 01:40:44
[2020-04-27 02:00:55]
JohnR - User831573 - Posts: 300
Flipper,

I can see my indebtedness to you is growing, as well as the qty of adult beverages I will owe you.

Thanks again for your time to share. I do try to help others in ways that I can to pay it forward.

JohnR
Date Time Of Last Edit: 2020-04-27 02:01:20

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

Login

Login Page - Create Account