Support Board
Date/Time: Tue, 24 Dec 2024 01:48:18 +0000
Post From: Using persistant array and also a persistant int variable
[2015-10-17 05:59:43] |
KhaosTrader - Posts: 128 |
Hi, I am wondering if I am implementing this code correctly, I am having some problem with my counter.. s_SwingInfo *p_LongSwings = (s_SwingInfo*)sc.GetPersistentPointer(1); int& NbrLongSwings = sc.GetPersistentInt(2); int& NbrShortSwings = sc.GetPersistentInt(3); if (sc.LastCallToFunction) { if (p_LongSwings != NULL) { sc.FreeMemory(p_LongSwings); sc.SetPersistentPointer(1, NULL); } return; if (NbrLongSwings != NULL) { sc.SetPersistentPointer(2, NULL); } } if (sc.UpdateStartIndex == 0) { NbrLongSwings = 0; NbrShortSwings = 0; } if (p_LongSwings == NULL) { //Allocate an array of 1024 doubles. p_LongSwings = (s_SwingInfo *)sc.AllocateMemory(20000 * sizeof(s_SwingInfo)); if (p_LongSwings != NULL) sc.SetPersistentPointer(1, p_LongSwings); else return; } |