Login Page - Create Account

Support Board


Date/Time: Mon, 23 Jun 2025 19:09:43 +0000



Post From: Sierra should allow ability to treat +/- FLT_MAX like it does sc.Subgraph[].DrawZeros=0

[2022-02-12 21:02:27]
User719512 - Posts: 316
I have included code below that describes the desired behavior and attached 2 files that show the desired study output and also an issue with the values scale (automatic) when a subgraph is set to +/- FLT_MAX.
Maybe the best way to describe the desired result is:
How to create a study that can display -1, 0, 1 when a condition is true and not display anything when the condition is false?
The idea is that +/- FLT_MAX could be used as values Sierra does not plot similar to how sc.DrawZeros can be used to not draw a plot and could be controlled with something like sc.DrawInfinity to preserve existing behavior and enable new functionality.


#include "sierrachart.h"


//
// FLT_MAX_Test
//
SCSFExport scsf_FLT_MAX_Test(SCStudyInterfaceRef sc)
{
SCSubgraphRef Subgraph_SG0 = sc.Subgraph[0];

SCInputRef Input_UseFloatMax = sc.Input[0];


if (sc.SetDefaults)
{
sc.GraphName = "zzz_FLT_MAX_Test";
sc.AutoLoop = 1;
sc.DrawZeros = 1;
sc.GraphRegion = 1;
sc.DrawStudyUnderneathMainPriceGraph = 0;

Subgraph_SG0.Name = "SG0";
Subgraph_SG0.DrawStyle = DRAWSTYLE_POINT;
Subgraph_SG0.LineWidth = 10;
Subgraph_SG0.PrimaryColor = RGB(0,255,0);

Input_UseFloatMax.Name = "Use FLT_MAX";
Input_UseFloatMax.SetYesNo(1);

return;
}


/*
The idea of this test is to have a way that Sierra shows the value scale properly
and also that like how sc.DrawZeros will not display a Subgraph on the chart for 0
we also would like Sierra to not display a Subgraph for FLT_MAX and -FLT_MAX
so Subgraphs can be initialized/used with these extreme values so a study can
display -1, 0, 1 for example during some time periods, and not display
anything during other time periods, like RTH (show) and Globex (hide).

For this example -1, 0, 1 are all valid values and what we want to display when
a given condition is true. There is currently no value you can set
for the Subgraph that will not display anything on the chart when a condition is false and
the study should not diplay anything during that time.

If we think of +/- FLT_MAX as Infinity, then the ask is to have a Subgraph property
like sc.DrawZeros named something like sc.DrawInfinity which could default to
true and not break existing behavior, but would not draw the Subgraphs for
cases 0 and 4 below when false.
*/

int mod = sc.Index % 8;

// When No, use +/- 2 which is really the value/condition we do not want to display.
// As of Sierra v2353, it does not show the values scale properly when we use +/- FLT_MAX.
switch (mod)
{
case 0:
Subgraph_SG0[sc.Index] = Input_UseFloatMax.GetYesNo() ? -FLT_MAX : -2.0f;
break;

case 1:
case 7:
Subgraph_SG0[sc.Index] = -1.0f;
break;

case 2:
case 6:
Subgraph_SG0[sc.Index] = 0;
break;

case 3:
case 5:
Subgraph_SG0[sc.Index] = 1.0f;
break;

case 4:
Subgraph_SG0[sc.Index] = Input_UseFloatMax.GetYesNo() ? FLT_MAX : 2.0f;
break;

default:
break;
}

}

Date Time Of Last Edit: 2022-02-12 21:02:52
imageSierra_FLT_MAX1.png / V - Attached On 2022-02-12 20:57:48 UTC - Size: 78.36 KB - 182 views
imageSierra_FLT_MAX2.png / V - Attached On 2022-02-12 20:58:02 UTC - Size: 39.75 KB - 180 views