Login Page - Create Account

Support Board


Date/Time: Sun, 06 Jul 2025 20:55:37 +0000



[Programming Help] - Help with custom horizontal study.

View Count: 1156

[2019-04-01 22:15:49]
ozunainc - Posts: 16
can any one tell me what "float" mean. im trying to get the value of a subgraph. form a refence studyid and it's subgraph, but i'm stuck. here is the code. "float GridStartVal = GridStart.GetFloat()-GridSpacingVal;".

I tried using:
GridStartVal = GridStart.SetChartStudySubgraphValues()-GridSpacingVal;

GridStarVal = GridStart.GetChartStudySubgraphValues()-GridSpacingVal;

GridStarVal = sc.Input[]. SetChartStudySubgraphValues()-GridSpacingVal;

but I keep getting error.

BTW i'm modifying the horizontal grid study so credit to whom ever created it. please help. I will post the source code here so everyone could use it. if I get it to work.

thank you for your time.
[2019-04-02 14:35:50]
Ackin - Posts: 1865
Hi,
what do you want to do in this code?

Float is a data type, number xxxx.xx
Command - "Set" - sets the value
Command - "Get" - reads value without change

You cannot use variables (which are calculated or defined later) in the input declaration.

put code here or write private message.
[2019-04-02 19:39:51]
ozunainc - Posts: 16
I just PM you Ackin. thank again
[2019-04-02 19:42:39]
ozunainc - Posts: 16
I did not wanted to share a wrong code with people here. When the study work. i'll posted for everyone to get it.
[2019-04-03 14:11:44]
Ackin - Posts: 1865
ozunainc)
Direct message - you have to allow me to send messages. ;)
[2019-04-03 19:22:25]
ozunainc - Posts: 16
ackin, I just did sorry about that. thanks again.
[2019-04-06 22:12:43]
ozunainc - Posts: 16
ackin did you get the code source I sent to you? if so can you tell me what im doing wrong as far as to the the value of the subgraph.

thanks.
[2019-04-06 22:31:47]
Ackin - Posts: 1865
Hi,
I answered you already via Direct message 2019-04-03 19:24:14 (included the corrected code)
[2019-04-08 14:48:41]
ozunainc - Posts: 16
Ackin, thank for the reply, but the code you send me is not what im looking for. I was able set a different STUDY by changing the code


" GridStart.SetFloat(7000.0f);" (ackin, this is used for manual inputs)



with "GridStart.SetStudySubgraphValues(0,0);" (which gives the option to pick a studyid and the studyid subgragh from the current chart).


my only problem is that i'm not see the values from the ref. studyid and subgraphid. I belive the code I need to change is in the data processing.

"float GridStartVal = GridStart.GetFloat()-GridSpacingVal;" (this is what I need to change)

WITH SAME THING LIKE : I just keep getting error.

// Do data processing

  //This will return sc.UpdateStartIndex or an earlier index if this study is calculated after a study which calculated at an earlier index and supports setting that earlier index.
  int ActualStartIndex = sc.GetCalculationStartIndexForStudy();

  // Get the array for the specified Input Data from the specified studies
  SCFloatArray Study1Array;
  sc.GetStudyArrayUsingID(Input_StudySubgraphReference.GetStudyID(), Input_StudySubgraphReference.GetSubgraphIndex(), Study1Array);

  for (int BarIndex = ActualStartIndex; BarIndex < sc.ArraySize; BarIndex++)
  {
    Subgraph_StudySubgraphReference[BarIndex] = Study1Array[BarIndex];
  }

  sc.EarliestUpdateSubgraphDataArrayIndex = ActualStartIndex;
}




Ackin, or any one please help Thanks again.

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

// For reference, refer to this page:
// Advanced Custom Study Interface and Language (ACSIL)

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

//This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require.
//*============================================================================*//


SCSFExport scsf_Studyshare(SCStudyGraphRef sc)
{
SCSubgraphRef L1 = sc.Subgraph[0];
SCSubgraphRef L2 = sc.Subgraph[1];
SCSubgraphRef L3 = sc.Subgraph[2];
SCSubgraphRef L4 = sc.Subgraph[3];
SCSubgraphRef L5 = sc.Subgraph[4];


SCInputRef GridStart = sc.Input[0];
SCInputRef GridSpacing = sc.Input[1];



if (sc.SetDefaults)
{
sc.GraphName = "Studyshare";

sc.ScaleRangeType = SCALE_SAMEASREGION;
sc.DrawZeros = 0;
sc.GraphRegion = 1;
sc.ValueFormat = 3;
sc.AutoLoop = 1;
sc.FreeDLL= 1;

GridStart.Name = "Grid Starting Number";
GridStart.SetStudySubgraphValues(0,0);
GridSpacing.Name = "Grid Spacing";
GridSpacing.SetFloat(0.05);

L1.Name = "L1";
L2.Name = "L2";
L3.Name = "L3";
L4.Name = "L4";
L5.Name = "L5";




return;
}

float GridSpacingVal = GridSpacing.GetFloat();
float GridStartVal = GridStart.GetFloat()-GridSpacingVal;

L1[sc.Index] = GridStartVal+GridSpacingVal;
L2[sc.Index] = GridStartVal+GridSpacingVal*2;
L3[sc.Index] = GridStartVal+GridSpacingVal*3;
L4[sc.Index] = GridStartVal+GridSpacingVal*4;
L5[sc.Index] = GridStartVal+GridSpacingVal*5;

}
[2019-04-08 15:33:55]
Ackin - Posts: 1865
So it was a misunderstanding of what you wanted


if you want to access a different reference variable from the graph you can use an array:



SCFloatArray Study1Array;
sc.GetStudyArrayUsingID(GridStart.GetStudyID(),GridStart.GetSubgraphIndex(),Study1Array);

float Value = Study1Array[sc.Index];


Date Time Of Last Edit: 2019-04-08 15:35:28
[2019-04-08 22:31:57]
ozunainc - Posts: 16
ackin, thank you so much. it works,but I do have a little modifying to do, before I could post a good source code. all I need to do is give negative value from the point of origin for line3 to line5 I believe or line4 to line5. I'm going to try it myself first, if I can not i'll ask for your help. thanks again ackin you are the best. P.S. once that part is done the study is complete and everyone could have it.
[2019-04-09 22:27:00]
ozunainc - Posts: 16
I just hope everyone could came with the own strategy and make money. thanks to ackin again.... enjoy. and to sierra chart if you like place this on the user contribute file. as promise...


// For reference, refer to this page:
// Advanced Custom Study Interface and Language (ACSIL)

// This line is required. Change the text within the quote
// marks to what you want to name your group of custom studies.
SCDLLName("auto horizontal line dll")

//This is the basic framework of a study function. Change the name 'TemplateFunction' to what you require.
//*============================================================================*//


SCSFExport scsf_AutoHorizontalLine(SCStudyGraphRef sc)
{
  SCSubgraphRef L1 = sc.Subgraph[0];
  SCSubgraphRef L2 = sc.Subgraph[1];
  SCSubgraphRef L3 = sc.Subgraph[2];
  SCSubgraphRef L4 = sc.Subgraph[3];    
  SCSubgraphRef L5 = sc.Subgraph[4];
  
  


  SCInputRef GridStart = sc.Input[0];
  SCInputRef GridSpacing = sc.Input[1];
  SCInputRef GridSpacingNegative = sc.Input[2];

  

  if (sc.SetDefaults)
  {
    sc.GraphName = "Ozuna Grid";

    sc.ScaleRangeType = SCALE_AUTO;
    sc.DrawZeros = true;
    sc.GraphRegion = 0;
    sc.ValueFormat = 3;
    sc.AutoLoop = 1;
    sc.FreeDLL= 1;

    GridStart.Name = "Grid Starting Number";
    GridStart.SetStudySubgraphValues(0,0);
    GridSpacing.Name = "Grid Spacing";
    GridSpacing.SetFloat(0.0f);
    GridSpacingNegative.Name = "Grid SpacingNegative";
    GridSpacingNegative.SetFloat(-0.0f);

    L1.Name = "L1";
    L2.Name = "L2";
    L3.Name = "L3";
    L4.Name = "L4";
    L5.Name = "L5";
    
  


    return;

  }

  float GridSpacingVal = GridSpacing.GetFloat();
  float GridSpacingValNegative = GridSpacingNegative.GetFloat();
  
  SCFloatArray Study1Array;
  sc.GetStudyArrayUsingID(GridStart.GetStudyID(),GridStart.GetSubgraphIndex(),Study1Array);
  float GridStartVal = Study1Array[sc.Index];

  L1[sc.Index] = GridStartVal+GridSpacingVal;
  L2[sc.Index] = GridStartVal+GridSpacingVal*2;
  L3[sc.Index] = GridStartVal+GridSpacingVal*3;
  L4[sc.Index] = GridStartVal+GridSpacingValNegative*1;
  L5[sc.Index] = GridStartVal+GridSpacingValNegative*2;


}

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

Login

Login Page - Create Account