Support Board
Date/Time: Fri, 28 Feb 2025 09:52:15 +0000
[Programming Help] - Custom study disappearing after removing an indicator
View Count: 516
[2021-08-16 15:23:38] |
BenjFlame - Posts: 335 |
Hi, I really can't explain this. Custom studies disappear from chart when I remove the built in Relative volume study. The custom study is NOT dependent on Relative volume. It calls some other subgraphs but these are on the chart. When I add back the relative volume study, and change timeframe, the custom study miraculously reappear. Why this strange behavior? How to solve the issue? Date Time Of Last Edit: 2021-08-16 17:42:15
|
[2021-08-16 17:52:04] |
John - SC Support - Posts: 38259 |
The only thing we can think of is that it could be a Region issue. Perhaps the custom study is expecting to be in a specific region and when you remove the Relative Volume it is changing the region. But really, we can not say. You would need to ask the developer of the custom study why this is occurring and what might be happening that is causing that custom study to disappear. For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2021-08-16 17:58:21] |
BenjFlame - Posts: 335 |
Thanks but it is not the solution. And I'm the developer of the study, although getting started with ACSIL. Do you spot something that could cause the issue in this: *============================================================================
Bar coloring VS volume average ----------------------------------------------------------------------------*/ SCSFExport scsf_BarColorAverageVolStrength(SCStudyInterfaceRef sc) { // Subgraphs name attributions SCSubgraphRef VolumeVsVolAverage_Sub = sc.Subgraph[0]; SCSubgraphRef VolumeAverageFromRef_Sub = sc.Subgraph[1]; // Create inputs SCInputRef Input_EnableSmoothing = sc.Input[0]; SCInputRef Input_WaitFiveSeconds = sc.Input[1]; SCInputRef Input_StudyId = sc.Input[2]; SCInputRef Input_SubgraphId = sc.Input[3]; if (sc.SetDefaults) { // Set the defaults sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.GraphName = "BAR COLORING: VS VOL AVG"; // Subrgraphs setup VolumeVsVolAverage_Sub.Name = "VOL STR VS VOL AVG"; VolumeVsVolAverage_Sub.DrawStyle = DRAWSTYLE_COLOR_BAR_HOLLOW; VolumeAverageFromRef_Sub.Name = "Volume Average from ref"; VolumeAverageFromRef_Sub.DrawStyle = DRAWSTYLE_HIDDEN; // Set inputs Input_EnableSmoothing.Name = "Enable Smoothing"; Input_EnableSmoothing.SetYesNo(0); Input_WaitFiveSeconds.Name = "Wait 5 Seconds"; Input_WaitFiveSeconds.SetYesNo(1); Input_StudyId.Name = "Study ID (Ma Simple on volume)"; Input_StudyId.SetInt(13); Input_SubgraphId.Name = "SubGraph ID"; Input_SubgraphId.SetInt(0); sc.AutoLoop = 1; // Enter any additional configuration code here return; } // Perform your data processing here. float vol = sc.Volume[sc.Index]; float Elapsed = sc.BaseDataEndDateTime[sc.Index].GetTimeInSeconds() - sc.BaseDateTimeIn[sc.Index].GetTimeInSeconds(); float SecondsPerBar = 0; float Multiplicator = 0; float VolumeProjection = 0; float VolumeProjectionPercentVsVolAvg = 0; float ElapsedPercent = 0; // Wait 5 sesconds if (Elapsed < 5 && Input_WaitFiveSeconds.GetInt() == 1) { return; } // If bar is proper time bar n_ACSIL::s_BarPeriod BarPeriod; sc.GetBarPeriodParameters(BarPeriod); if (BarPeriod.ChartDataType == INTRADAY_DATA && BarPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS && Elapsed > 0 ) { // Build vol moving average from the other study on chart SCFloatArray StudyReferenceVol; float VolMovingAverage = 0; if (sc.GetStudyArrayUsingID(Input_StudyId.GetInt(), Input_SubgraphId.GetInt(), StudyReferenceVol) > 0 && StudyReferenceVol.GetArraySize() > 0) { //Copy the study data that we retrieved using GetStudyArrayUsingID, into a subgraph data output array VolumeAverageFromRef_Sub[sc.Index] = StudyReferenceVol[sc.Index]; VolMovingAverage = VolumeAverageFromRef_Sub[sc.Index]; } SecondsPerBar = BarPeriod.IntradayChartBarPeriodParameter1; Multiplicator = SecondsPerBar / Elapsed; VolumeProjection = vol * Multiplicator; // Smoothing the projection if (Input_EnableSmoothing.GetInt() == 1) { ElapsedPercent = (Elapsed * 100) / SecondsPerBar; if (ElapsedPercent <= 9 ) { VolumeProjection *= 0.60; } else if (ElapsedPercent >= 10 && ElapsedPercent <= 19) { VolumeProjection *= 0.70; } else if (ElapsedPercent >= 20 && ElapsedPercent <= 30) { VolumeProjection *= 0.80; } else { VolumeProjection *= 1; } } VolumeProjectionPercentVsVolAvg = ( VolumeProjection * 100) / VolMovingAverage; VolumeVsVolAverage_Sub[sc.Index] = VolumeProjectionPercentVsVolAvg; // Outline coloring SCSubgraphRef CalculationChoice = VolumeVsVolAverage_Sub; if (CalculationChoice[sc.Index] >= 0 && CalculationChoice[sc.Index] <= 14 ) { CalculationChoice.DataColor[sc.Index] = RGB(35, 35, 35); } else if (CalculationChoice[sc.Index] > 209 && CalculationChoice[sc.Index] <= 224) { CalculationChoice.DataColor[sc.Index] = RGB(242, 255, 0); } else if (CalculationChoice[sc.Index] > 224 ) { CalculationChoice.DataColor[sc.Index] = RGB(255, 255, 255); } return; } return; } Date Time Of Last Edit: 2021-08-16 17:59:42
|
[2021-08-16 21:09:05] |
BenjFlame - Posts: 335 |
Hi, this is a question for Sierrachart people as it might not be due to a custom problem. I spotted the exact reason of my problem: float Elapsed = sc.BaseDataEndDateTime[sc.Index].GetTimeInSeconds() - sc.BaseDateTimeIn[sc.Index].GetTimeInSeconds();
When relative volume (which has NOTHING to do with this study) is on the chart, Elapsed correctly returns seconds from beginning of current bar. When relative volume is on the chart, the behavior of this calculation changes. It reports a huge negative number that accumulates, as if it counts bars on chart. So why does SierraChart functions produce different results when relative volume is on chart or not? Date Time Of Last Edit: 2021-08-16 21:11:53
|
[2021-08-16 21:25:55] |
John - SC Support - Posts: 38259 |
What is your Based On set to? Is this set to the Relative Volume study?
For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2021-08-16 21:42:18] |
BenjFlame - Posts: 335 |
No it is not. It's based on main price. I set sc.MaintainAdditionalChartDataArrays to 1. When I isolate the indicator in it's own file it displays correctly even without relative volume. Same code inside file with my other study: I remove it, add it: it displays fine. I switch timeframe (to 10s from 1 mn or vice versa), it disappear again. SO same code works fine in own file, but not in file with other studies. |
[2021-08-16 22:10:03] |
BenjFlame - Posts: 335 |
Now all is working as expected. Seems sc.MaintainAdditionalChartDataArrays to 1. solved the issue, but not right away. Not sure if it makes any sense and would explain 'Elapsed' to be different depending on the presence of relative volume study. I will continue to monitor this. |
To post a message in this thread, you need to log in with your Sierra Chart account: