How to execute code once in the Strategy Monitor?
Author: Frank1972
Creation Date: 12/9/2016 9:45 PM
profile picture

Frank1972

#1
Hi,

Where should I do things that I only want executed once? What I'm trying to do is connect to a TCP socket and as orders come in, through that socket, I will process them. So do I do my connection logic in Execute or some other method.

I'm not sure how the Strategy Monitor is going to execute my script. My script will be running on 1 minute bars. I would like the connection to be established once and then used by the script on subsequent executions.

Is this possible?

Thanks,

-Frank
profile picture

Eugene

#2
Hi Frank,

For cases like this you'd want to use the Singleton pattern

https://www.dotnetperls.com/singleton
http://csharpindepth.com/Articles/General/Singleton.aspx

Wealth-Lab's global memory might help. Check this out: WealthScript Techniques | Executing some code only once
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).