File I/O From Strategy under Strategy Monitor
Author: ronc
Creation Date: 4/22/2020 6:33 PM
profile picture

ronc

#1
My strategy code writes various data via a) PrintDebug() and b) writing to text files via e.g.File.WriteAllLines() and File.WriteAllText(). I also read data from files via StreamReader. These all work fine when I run the strategy via Editor > Run the Strategy.

However, when I put the strategy into the Strategy Monitor and start periodic execution, PrintDebug and file writing does not occur. Not sure about file reading yet. I have enabled logging for the strategy in the Strategy Monitor but the resulting log contains Strategy Monitor events, not the logging from my code.

How do I enable file I/O for a strategy running under the control of the Strategy Monitor?

WL Pro 6.9 64 bit.

Thanks!
profile picture

Eugene

#2
The Debug window will not appear when invoked from the Strategy Monitor as all cosmetic chart (drawing, accessing ChartPanes etc) and debug log methods are intentionally disabled in SM and Combination Strategies. As a workaround, try CommentaryWindow from C.Components or SetGlobal() (to store the log lines in WL's global memory to be read by GetGlobal() in a Strategy window).
profile picture

ronc

#3
Thanks Eugene. The PrintDebug/Commentary logging I can live without, but file I/O is critical. I read / write files at run time to exchange data with my other code outside of WLP.

Does Strategy Monitor disable file reading/writing?

Yes,I can use Set/GetGlobal to exchange data between the "primary" strategy and a secondary strategy. But if the secondary strategy is also running under Strategy Monitor, and if Strategy Monitor disables file I/O, then how can the secondary strategy read/write files?
profile picture

Eugene

#4
QUOTE:
Does Strategy Monitor disable file reading/writing?

No. You should be able to do both. If not, you're doing something wrong.
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).