Support Board
Date/Time: Wed, 27 Nov 2024 08:42:09 +0000
Post From: DRAWSTYLE_IGNORE isn't ignoring.
[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
|