Support Board
Date/Time: Tue, 24 Dec 2024 02:30:19 +0000
persistant array of structs
View Count: 1572
[2015-10-15 10:08:05] |
KhaosTrader - Posts: 128 |
Hi, Is there a way to make a persistant array of stucts? Thanks |
[2015-10-15 10:12:13] |
KhaosTrader - Posts: 128 |
I want to make my own array that holds swing values. I have several data elements that I store for each swing occurance. I was thinking of holding these different data values in a struct, then having an array of these structs hold my swing values for each swing, which I can reference in relation to each other in my formulas on the chart.
Date Time Of Last Edit: 2015-10-15 10:13:11
|
[2015-10-15 10:45:06] |
KhaosTrader - Posts: 128 |
If cant do an array of persistant structs, can I make a persistant array that holds a number of elements that I define? Not one per bar sort of thing?
|
[2015-10-15 17:32:21] |
Sierra Chart Engineering - Posts: 104368 |
Yes this can be done. Refer to the documentation for this here: https://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#DynamicMemoryAllocations Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-10-16 21:00:25] |
KhaosTrader - Posts: 128 |
Hi, I believe got my array of structs to work, thanks .... I have 2 other questions. 1) if I want to just have a persistent integer for a counter or something, should I use the same code structure? 2) If I want to have a collection of classes or array of classes, rather than an array of structs, could I use the structure you recommended me for structs for that? Thanks |
[2015-10-28 04:02:41] |
Sierra Chart Engineering - Posts: 104368 |
The documentation for your questions has now been prepared here: https://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#GettingAndSettingPersistentData Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-10-29 21:09:21] |
KhaosTrader - Posts: 128 |
Hi, I am using an array of structs, not classes, so is this code correct? Thank you for your kind help. int& NbrLongSwings = sc.GetPersistentInt(3); int& NbrShortSwings = sc.GetPersistentInt(4); s_SwingInfo* p_LongSwings = (s_SwingInfo*)sc.GetPersistentPointer(1); s_SwingInfo* p_ShortSwings = (s_SwingInfo*)sc.GetPersistentPointer(2); if (sc.UpdateStartIndex == 0) { NbrLongSwings = 0; NbrShortSwings = 0; } if (sc.LastCallToFunction) { if (p_LongSwings != NULL) { delete p_LongSwings; sc.SetPersistentPointer(1, NULL); } if (p_ShortSwings != NULL) { delete p_ShortSwings; sc.SetPersistentPointer(2, NULL); } return; } if (p_LongSwings == NULL) { //Allocate an array of 20k structs. p_LongSwings = (s_SwingInfo *) new s_SwingInfo[20000]; if (p_LongSwings != NULL) sc.SetPersistentPointer(1, p_LongSwings); else return; } if (p_ShortSwings == NULL) { //Allocate an array of 20k structs. p_ShortSwings = (s_SwingInfo *) new s_SwingInfo[20000]; if (p_ShortSwings != NULL) sc.SetPersistentPointer(2, p_ShortSwings); else return; } Date Time Of Last Edit: 2015-10-29 22:25:15
|
[2015-10-29 23:30:00] |
Sierra Chart Engineering - Posts: 104368 |
In the case of an array of structures, there is no need to use new and delete.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-10-29 23:57:45] |
KhaosTrader - Posts: 128 |
Ok I had some troubles, I had to remove the dll from the chart and re-apply it... I rewrote the code here, please tell me if its correct, I am using 2 arrays, and 2 counter int vars... s_SwingInfo* p_LongSwings = (s_SwingInfo*)sc.GetPersistentPointer(1); s_SwingInfo* p_ShortSwings = (s_SwingInfo*)sc.GetPersistentPointer(2); int& NbrLongSwings = sc.GetPersistentInt(3); int& NbrShortSwings = sc.GetPersistentInt(4); if (sc.UpdateStartIndex == 0) { NbrLongSwings = 0; NbrShortSwings = 0; } if (sc.LastCallToFunction) { if (p_LongSwings != NULL) { delete p_LongSwings; sc.SetPersistentPointer(1, NULL); } if (p_ShortSwings != NULL) { delete p_ShortSwings; sc.SetPersistentPointer(2, NULL); } if (NbrLongSwings != NULL) { sc.SetPersistentPointer(3, NULL); } if (NbrShortSwings != NULL) { sc.SetPersistentPointer(4, NULL); } return; } if (p_LongSwings == NULL) { //Allocate an array of 20k structs. p_LongSwings = (s_SwingInfo *) new s_SwingInfo[20000]; if (p_LongSwings != NULL) sc.SetPersistentPointer(1, p_LongSwings); else return; } if (p_ShortSwings == NULL) { //Allocate an array of 20k structs. p_ShortSwings = (s_SwingInfo *) new s_SwingInfo[20000]; if (p_ShortSwings != NULL) sc.SetPersistentPointer(2, p_ShortSwings); else return; } Date Time Of Last Edit: 2015-10-30 00:19:16
|
[2015-10-30 00:41:45] |
Sierra Chart Engineering - Posts: 104368 |
We do not provide programming help. You will have to analyze your own code. We do not do that.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-10-30 01:19:38] |
Sierra Chart Engineering - Posts: 104368 |
What we can do for you though is put together an example for structures and we will do that.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing |
[2015-10-30 05:36:06] |
KhaosTrader - Posts: 128 |
Ok yes that would be helpful, especially if we use 2 or more structs in the program and 2 or more counters. Thank you. |
To post a message in this thread, you need to log in with your Sierra Chart account: