Login Page - Create Account

Support Board


Date/Time: Tue, 19 Mar 2024 02:41:20 +0000



[Programming Help] - How to use DRAWSTYLE_POINT_VARIABLE_SIZE? Getting strange painting and chart scale.

View Count: 754

[2021-04-07 20:19:12]
User719512 - Posts: 225
I have looked at the docs at https://www.sierrachart.com/index.php?page=doc/ChartStudies.html#DrawStyle_PointVariableSize, and getting unexpected results. Is there an example for DRAWSTYLE_POINT_VARIABLE_SIZE, or does anyone have suggestions on how I am using this DrawStyle incorrectly? Example code below. I expected a variable sized point at the sc.Close/Last price. What I am seeing is points at F.US.EPM21 prices like 4072.200, 4072.400 and not 4072.25, 4072.50, etc.



SCSFExport scsf_OSC_TestVariablePoint(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_VariableVolume = sc.Subgraph[0];

if (sc.SetDefaults)
{
sc.GraphName = "Variable Points";
sc.StudyDescription = "Variable Sized Points Test";

// sc Control variables
sc.AutoLoop = 1;
sc.DisplayAsMainPriceGraph = 1;

Subgraph_VariableVolume.Name = "Variable Volume Points";
Subgraph_VariableVolume.DrawStyle = DRAWSTYLE_POINT_VARIABLE_SIZE;
Subgraph_VariableVolume.PrimaryColor = RGB(128, 128, 128);

return;
}

// for testing, just generate a random number for the Size.
// just take a remainder of time for size 1-5.
int size = sc.BaseDateTimeIn[sc.Index].GetSecond() % 5 + 1;

Subgraph_VariableVolume[sc.Index] = sc.Close[sc.Index];
Subgraph_VariableVolume.Data[sc.Index] = sc.Close[sc.Index];
Subgraph_VariableVolume.Arrays[0][sc.Index] = size;
}

[2021-04-08 06:50:11]
User907968 - Posts: 795
Check the value format used by the study - Chart Studies: Settings and Inputs Tab >> Value Format

Maybe include the following (or similar) in the SetDefaults block:
sc.ValueFormat = VALUEFORMAT_INHERITED;

Also, not related to your specific question but, these lines both perform the same operation:

Subgraph_VariableVolume[sc.Index] = sc.Close[sc.Index];

Subgraph_VariableVolume.Data[sc.Index] = sc.Close[sc.Index];

The first line is a shorthand version of the second (ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].Data[] / sc.Subgraph[][])
[2021-04-08 07:48:20]
User719512 - Posts: 225
Thank you for the tip on the ".Data". I tried the setting for ValueFormat and the result is the same. Chart settings shows Price Display Format as "0.01", but I am seeing whole numbers on the price scale.
[2021-04-08 09:29:01]
User907968 - Posts: 795
Yes, ok, most likely because you have display as main price graph enabled (sc.DisplayAsMainPriceGraph = 1;), so there is no price chart to inherit the value format from, in which case try manually setting the value format to an appropriate value in the study settings window.
[2021-04-08 18:20:57]
User719512 - Posts: 225
Just discovered this does not work if the Graph Draw Type is Blank. My study started working as expected once I set the Graph Draw Type to non-Blank (Line, Stair Step on Close, etc).

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

Login

Login Page - Create Account