How to Differentiate Strategy Monitor from Multi-symbol Backtest
Author: LenMoz
Creation Date: 4/17/2013 12:54 PM
profile picture

LenMoz

#1
I only want to send my custom emails when the strategy is running under Strategy Monitor. Is there a way to recognize this from code?

I've tried IsPricePane and ChartStyle == Null without success. Here's my code...

CODE:
Please log in to see this code.
profile picture

Eugene

#2
PrintDebug is N/A in Strategy Monitor.

This approach (i.e. ChartStyle == null) from QuickRef > ChartStyle works flawlessly here. Regardless of the mode: single symbol and multi-symbol alike.
profile picture

LenMoz

#3
Hmmm You did a multisymbol backtest? Only works for single symbol for me. Multisymbol backtest acts like Strategy Monitor.

And it's surprising that yours works because the QuickRef says, "If the Strategy is run in a context where there is no chart (such as the Strategy Monitor or a Multi-Symbol Backtest), this property returns null."
profile picture

Eugene

#4
Just to confirm, I did an SSB and an MSB in the Strategy Monitor. Both returned the expected result.

Now that I re-read your thread title carefully, I realize that you're asking to tell SM from MSB... This might help:

Programming | Determining the mode a Strategy is running in
profile picture

LenMoz

#5
We're getting there. Thanks for your help.

I need a function that returns true for Strategy Monitor, but false for every other case that may run a strategy, SSB, MSB, Optimizer, etc.,

I want to be able to make changes to and test a strategy, using SSB or MSB, without sending email.

"return ChartStyle == null;" returns true for Strategy Monitor and also MSB, false for SSB. So, I send emails whenever I run a test with MSB, which I don't want.



profile picture

Eugene

#6
There is no such function. SM, MSB and Optimizer are alike - there is no chart. SSB has charts.

Here's how to detect Optimization:

CODE:
Please log in to see this code.


Let me see if I find a key to tell SM from anything else using Reflection...
profile picture

LenMoz

#7
Thanks again. Perhaps this thread should be retitled, "How to detect Strategy Monitor execution".

One work-around is to just add a parameter that is only set to "1" in Strategy Monitor, having the benefit of working even if form attributes change in future releases. This was my original thought.
profile picture

Eugene

#8
IMHO your solution is by far the easiest. :)
profile picture

vladl2015

#9
I had same need to distinguish is my WL script run in Strategy Monitor, SSB or MSB mode.
Suggestions/code I found at forum and FAQ were some way incomplete so I wrote my own function.

It's using ideas and posts including FAQ and this http://www.wealth-lab.com/Forum/Posts/29114
with some extra.

CODE:
Please log in to see this code.


Please notice:
1) The function based on current WL behaviors and GUI object names, which may be changed by WL developers later.

2) This function can't detect SM when StrategyMonitor is not active window.
In case you started SM but later open a regular strategy window on top this function will return SSB/MSB while actually it may be in "SM".
So this function should be used as SM detector only when SM is the only strategy running window opened in WL.
profile picture

Eugene

#10
Vlad,

Thanks for sharing this! Now the question is, will this code work in Wealth-Lab Pro. Can't check it right now but the names of some controls (pnlTree, cmbSymbol) may be obfuscated in WLP:
CODE:
Please log in to see this code.
profile picture

vladl2015

#11
Ummm... in case it fails I see workaround, at least for StrategyMonitor detection:
there is "Symbol" text label at left to drop-down box. It probably can be found enumerating controls by its constant text.
And that label has same habit: its text disabled/grayed during StrategyMonitor activity :)
profile picture

Eugene

#12
ATTENTION: Community Components has a new GetMode function since v2017.09. It supersedes the Wiki article and related forum conversations. Thanks vladl2015 for the code.

GetMode
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).