Hello, I'm authoring some code using the default WealthLab C# language. I'm attempting to have the same snippet of code be something I execute and either backtest on a dataset or run on streaming data to execute trades in realtime. There is a laborious way to do this by replicating my code based on a 'normal' conditional if I set something like "am I backtesting or not", but this will basically cause me to replicate most of my code adjusting for only the current bar and few other minor details.
But I would like to use a #define and #if convention within C# instead to avoid replicating my code. This will cause portions of my code to be either executed or ignored depending on if I'm trying to backtest or stream and execute realtime trades.
Thoughts? I'm becoming convinced this isn't something supported by WealthLab Pro...
Cheers and thanks!
Size:
Color:
Hi,
Although I'm not convinced that the preprocessor directives should not work, why can't code detect the mode it runs in by querying the IsStreaming property? Or is your question different?
Size:
Color:
Maybe create a true/false parameter, "paramIsStreaming", having values 0 and 1?
CODE:
Please log in to see this code.
When optimizing, set the CreateParameter locked to zero - (0, 0, 0, 1)
Size:
Color:
Maybe simpler?
CODE:
Please log in to see this code.
Size:
Color:
Thanks all for the responses and suggestions, much appreciated! I'm going over the options now and evaluating how best to proceed. But it is somewhat obvious now no matter what method I use to separate the backtesting vs. streaming I'll need distinct (and somewhat redundant) sets of code so nothing gained by using any potential preprocessor directive.
Cheers!
Size:
Color: