Support Board
Date/Time: Sun, 05 May 2024 03:20:35 +0000
Post From: Question about initialization of variables
[2019-03-13 22:11:10] |
User257019 - Posts: 25 |
Hello team, my apologies, I just understood better persistent variables and made it work. Just in case someone else wants to know: SCSFExport scsf_DrawMaxAndMin(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { ... } float& maximum = sc.GetPersistentFloat(1); float& minimum = sc.GetPersistentFloat(2); if (sc.IsFullRecalculation && sc.Index == 0) { sc.GetPersistentFloat(1) = 100.0; sc.GetPersistentFloat(2) = 100000.0; } if (sc.Index == sc.ArraySize - 1) // Only calculated for the latest bar { float currentHigh = sc.BaseDataIn[SC_HIGH][sc.Index]; float currentLow = sc.BaseDataIn[SC_LOW][sc.Index]; if (maximum < currentHigh) maximum = currentHigh; if (minimum > currentLow) minimum = currentLow; SCString DebugMessage; // Log minimum value DebugMessage.Format("Minimum=%f", minimum); sc.AddMessageToLog(DebugMessage, 0); // Log maximum value DebugMessage.Format("Maximum=%f", maximum); sc.AddMessageToLog(DebugMessage, 0); } } |