Login Page - Create Account

Support Board


Date/Time: Thu, 28 Mar 2024 10:47:11 +0000



Can I persist a custom object?

View Count: 1995

[2013-05-28 21:59:56]
drmrboyc - Posts: 7
Hello,

I've built a custom class, which is implemented in a separate .h & .cpp file included in my Custom DLL project. In my main cpp file, I instantiate the object after the SCDLLName("DLLName") function call, but before the scsf_MainFunction().

I'm using the syntax:

Object myObject;

Then inside scsf_MainFunction()-sc.SetDefaults code block, I initialize the object with a call:

myObject.InitializeObject("Custom Params");

The object takes the "Custom Params" string and stores it for later use, however, when I attempt to access that information during a later call, it is gone!

I believe this is related to object persistence between bars, but I could be doing something else wrong and just not see it.

Is there any particular method I can use to persist my object between bars?

Thank you!

Kenny
[2013-05-28 22:41:37]
Sierra Chart Engineering - Posts: 104368
Make sure you set sc.FreeDLL = 0 in the sc.SetDefaults code block. That will solve the problem.
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
[2013-05-29 17:34:35]
drmrboyc - Posts: 7
Thank you for your reply!

I tried setting sc.FreeDLL = 0, however, the problem persisted.

I went ahead and stepped through the code just to make sure I knew exactly what was happening.

When the Study is first added to the chart, sc.SetDefaults is true and myObject is properly initialized. When the study is actually run for the first time, myObject is NULL again.

I tried using a pointer instead, but the same thing happened.

Is there anything other than FreeDLL that I can try to persist the object?

Another option, that I thought I might try, is to initialize a pointer of the object, save the memory address into one of SC's PersistVars, then somehow re-point the pointer to that memory address each time the study is run. But that seems really hack-y to me, and I'm sure there's a better way to do it.

Thanks so much for you help!

Kenny
[2013-05-30 00:16:57]
Sierra Chart Engineering - Posts: 104368
Do the initialization of your object outside of sc.SetDefaults. Refer to this section as a reference:
http://www.sierrachart.com/index.php?l=doc/doc_ACSILProgrammingConcepts.html#DynamicMemoryAllocations

We have to confirm this, but probably during the call to sc.SetDefaults the DLL is loaded and released and the sc.FreeDLL variable is ignored. This may have been the case in the past, but not sure if it is still the case. We thought we changed this so it is not released but maybe it still is.

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
Date Time Of Last Edit: 2013-05-30 00:19:01
[2013-06-03 23:56:25]
Sierra Chart Engineering - Posts: 104368
We have to confirm this, but probably during the call to sc.SetDefaults the DLL is loaded and released and the sc.FreeDLL variable is ignored


This has been confirmed to be the case. And in the latest prerelease this is no longer the case. Once the custom study is added to the chart, the DLL is loaded and not freed as long as sc.FreeDLL = 0.
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
[2013-06-05 16:10:09]
drmrboyc - Posts: 7
Thank you!

I downloaded and tested it with Pre-release version 983. It worked perfectly now!
[2013-06-05 17:24:11]
Sierra Chart Engineering - Posts: 104368
OK good.
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

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account