Preprocessor Directive for Backtesting vs. Streaming?
Author: 911C4S_991
Creation Date: 1/21/2018 7:56 PM
profile picture

911C4S_991

#1
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!
profile picture

Eugene

#2
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?
profile picture

LenMoz

#3
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)
profile picture

Eugene

#4
Maybe simpler?
CODE:
Please log in to see this code.
profile picture

911C4S_991

#5
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!
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).