Support Board
Date/Time: Sat, 28 Jun 2025 21:19:07 +0000
Post From: Sample Code for sc.GetStudyLineUntilFutureIntersectionByIndex()
[2020-10-26 20:41:05] |
User253985 - Posts: 23 |
The code below gives the output as per the attached picture 'Line until Intersection.PNG' when it is recalculated it gives the output of 'Line until Intersection 2.PNG' It doesn't replace upon recalculation it adds to the variable. The Actual Number of Lines Until future Intersection is not increasing. #include "sierrachart.h" SCDLLName("Get Future Intersection Lines") SCSFExport scsf_IntersectionLines(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Reference Study Data"; sc.StudyDescription = "Referencing data from other studies on the chart."; sc.AutoLoop = 0; // low precedence level to ensure other studies are calculated first. sc.CalculationPrecedence = LOW_PREC_LEVEL; sc.Input[1].Name = "Study Reference"; sc.Input[1].SetStudyID(1); return; } // choose spreadsheet to put data on const char* SheetCollectionName = "IntersectionTester"; const char* SheetName = "Intersection"; void* SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false); sc.SetSheetCellAsString(SheetHandle, 0, 0, "Index"); sc.SetSheetCellAsString(SheetHandle, 1, 0, "Line ID For Bar"); sc.SetSheetCellAsString(SheetHandle, 2, 0, "Start Index"); sc.SetSheetCellAsString(SheetHandle, 3, 0, "Line Value"); sc.SetSheetCellAsString(SheetHandle, 4, 0, "Extension Line Chart Column End Index"); sc.SetSheetCellAsString(SheetHandle, 5, 0, "Number of Lines"); int LineIDForBar = 0; int StartIndex = 0; float LineValue = 0; int ExtensionLineChartColumnEndIndex = 0; int Index = 0; Index = sc.GetNumLinesUntilFutureIntersection(sc.ChartNumber, sc.Input[1].GetStudyID()) - 1; sc.SetSheetCellAsDouble(SheetHandle, 5, 1, Index); for (Index; Index >= 0; Index--) { sc.GetStudyLineUntilFutureIntersectionByIndex(sc.ChartNumber, sc.Input[1].GetStudyID(), Index, LineIDForBar, StartIndex, LineValue, ExtensionLineChartColumnEndIndex); // Set labels in Row 1. {SheetHandle, Column, Row, Value} sc.SetSheetCellAsDouble(SheetHandle, 0, Index + 1, Index); sc.SetSheetCellAsDouble(SheetHandle, 1, Index + 1, LineIDForBar); sc.SetSheetCellAsDouble(SheetHandle, 2, Index + 1, StartIndex); sc.SetSheetCellAsDouble(SheetHandle, 3, Index + 1, LineValue); sc.SetSheetCellAsDouble(SheetHandle, 4, Index + 1, ExtensionLineChartColumnEndIndex); } } Date Time Of Last Edit: 2020-10-26 20:43:02
|
![]() ![]() |