Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 08:36:11 +0000



[Programming Help] - DRAWSTYLE_IGNORE isn't ignoring.

View Count: 346

[2023-09-03 19:53:40]
j4ytr4der_ - Posts: 938
I have made a study that is essentially a "Multiple Spreadsheet Formula" study. It takes up to 16 formulas and parses them all for the current chart.

For some reason I can't seem to figure out, only the first input (SG1) refuses to "ignore" if I set its draw style to ignore.

I'm testing with the formula
BARTIME > 0
which should output TRUE for every bar, and does.

If I put this formula in any input other than the first one, then I can set the draw style to Background and I get a colored background on every bar, as I would expect. If I set it to Hidden, then the chart scale gets messed up as it shows all the way down to zero. I think this is expected behavior but I'm not totally sure. But if I set it to ignore, then the drawing is ignored entirely, the chart scale is normal, everything is fine as it should be.

Now if I move that formula to the first input, then it will never draw the scale correctly. It will always show zeros, even if set to ignore. I'm using
sc.DrawZeros = false;
and
sc.Subgraph[i].DrawZeros = false;
(the latter during my loop to generate the study inputs) but they don't seem to have any effect.

Any suggestions on what could be causing this issue, only when using the first input?

Here is my code currently.


/*==============================================================================
  Outputs the result of up to 16 formulas to subgraphs
  Inspired by @gcUserStudies
------------------------------------------------------------------------------*/

SCSFExport scsf_MultiFormulaSubgraphOutput(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.MaintainVolumeAtPriceData = 1;
    sc.UsesMarketDepthData = 1;    
    sc.GraphName = "JVC Multi-Formula Subgraph Output";
    sc.GraphRegion = 2;
    sc.AutoLoop = 0; // auto looping on or off
    sc.DrawZeros = false;
    sc.CalculationPrecedence = LOW_PREC_LEVEL;
      
    SCString MyName; // Placeholder for the input/subgraph names
    
    for(int i = 0; i < 16; i++){ // Loop to build all the inputs and subgraphs
      sc.Input[i].Name = MyName.Format("Formula %d", i);
      sc.Input[i].SetDescription("Spreadsheet Formula");
      sc.Input[i].SetString("");

      sc.Subgraph[i].Name = MyName.Format("Formula %d", i);
      sc.Subgraph[i].DrawStyle = DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY;
      sc.Subgraph[i].DrawZeros = false;
    }
    
    sc.Input[16].Name = "Calculate historical bars? (Adds latency)";
    sc.Input[16].SetDescription("Should this study process for every bar in the chart?");
    sc.Input[16].SetYesNo(0);

    sc.Input[17].Name = "DISABLE STUDY";
    sc.Input[17].SetDescription("Enable/Disable study");
    sc.Input[17].SetYesNo(0);
    
    return;
  }
  
  if(sc.Input[17].GetYesNo() == 1){
    return; // If the study is disabled, exit without doing anything.
  }
  
  for(int InputIndex = 0; InputIndex < 16; InputIndex++) // Loop through each input
  {
    SCString check = sc.Input[InputIndex].GetString(); // Grab the formula for the chosen input

    if(check.IsEmpty()){ // Skip to the next input if this one is empty
      continue;
    }

    const char* Formula = sc.Input[InputIndex].GetString(); // Grab the formula for the chosen input

    if(sc.Input[16].GetYesNo() == 0) // Calculate only for current bar - near-zero latency
    {
      double FormulaOutput = sc.EvaluateGivenAlertConditionFormulaAsDouble(sc.Index, TRUE, Formula); // Evaluate the formula

      sc.Subgraph[InputIndex][sc.Index] = (float)FormulaOutput; // Return the formula result in a subgraph
    }else //calculate for all historical bars
    {
      for (int BarIndex = sc.UpdateStartIndex; BarIndex < sc.ArraySize; BarIndex++)
      {
        double FormulaOutput = sc.EvaluateGivenAlertConditionFormulaAsDouble(BarIndex, TRUE, Formula); // Evaluate the formula

        sc.Subgraph[InputIndex][BarIndex] = (float)FormulaOutput; // Return the formula result in a subgraph
      }
    }
  }
}

Date Time Of Last Edit: 2023-09-04 16:34:39
[2023-09-07 01:49:31]
j4ytr4der_ - Posts: 938
I have narrowed this down and it seems this is not what it appeared. The actual culprit, is a simple calculation where I want to view the subgraph data but no visuals, so I have it set to DRAWSTYLE_SUBGRAPH_NAME_AND_VALUE_LABELS_ONLY. The formula is
ID3.SG1/ID2.SG1

Very simple, just calculating a percentage. But since this returns close to zero (a decimal percentage), it is causing the value scale to adjust to reflect all the way down to that number below 1. Setting it to ignore, does in fact cause it to not draw at all and the value scale to be correct. But setting it to subgraph name & values only, should (as far as I understand) also not impact the value scale. So why is it doing so, and how can I get it to stop?
Date Time Of Last Edit: 2023-09-07 01:49:43
[2023-09-07 14:23:06]
John - SC Support - Posts: 36309
That subgraph style does impact the scale. You need to change the scaling for that study to be "Same as Region" and not "Automatic".
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2023-09-07 15:09:25]
j4ytr4der_ - Posts: 938
Ahhhh of course, scaling for just the study! I totally overlooked that. Will give that a go, much appreciated!

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

Login

Login Page - Create Account