Why doesn't a loop by DataSetSymbols generate Alerts in Strategy Monitor?
Author: Panache
Creation Date: 1/30/2018 7:11 PM
profile picture

Panache

#1
When I run the following Strategy, it generates an Alert as expected:

CODE:
Please log in to see this code.


However, when it is run in Strategy Monitor, it doesn't generate any Alerts.

I understand
QUOTE:
The Strategy Monitor runs the Strategy individually for each symbol as soon as the data is available.
. However, I don't understand why that would prevent Strategy Monitor from generating at least one Alert.
profile picture

Eugene

#2
This strategy cannot and will not generate Alerts anywhere as it does not meet at least two requirements as per this FAQ > Alerts are not triggered:

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

Panache

#3
I wouldn't expect to see BuyAtClose Alerts.

I created this simple Strategy to try to debug a more complicated Strategy and reproduce the fact that
CODE:
Please log in to see this code.

isn't generating an Alert in Strategy Monitor.

The simpler demo

CODE:
Please log in to see this code.

generates the BuyAtClose Alert in Strategy Monitor as expected.

profile picture

Panache

#4
Here's an even weirder result.

CODE:
Please log in to see this code.


This code runs as expected in Strategy Monitor, generating one BuyAtClose Alert. However, if
CODE:
Please log in to see this code.

is active, no Alerts OF ANY KIND are generated.

Obviously, Strategy Monitor is seen the number of active positions. However, it appears not to be seeing the position that was opened. When I look at the Action column, it says, "Run Now Ended", so I assume it is throwing some kind of error.
profile picture

Eugene

#5
Here's a classic reply by Cone that should help shed light on what's wrong with that code in your post #4 above:

IsLastPositionActive remains false in Strategy Monitor
profile picture

Panache

#6
Thanks Eugene. I understand now.

I keep trying to find ways to work around the limitations of Strategy Monitor and keep coming up empty.

What I'd like to be able to do when I am away is to keep Wealth-Lab Pro running 24/7, have Data Manager update the daily data every day, run my Strategies each day and email me the Alerts to trade on.

I don't recall what the issue was with emailing Alerts, but I hard coded those into my Strategies, so that is no longer an issue.

For rotational Strategies, I can't use PosSizers to generate Alerts, so I also hard coded the PosSizer into my Strategies. The problem is that if Strategy Monitor isn't seeing the open positions, it isn't generating any closing signals. If the built in PosSizer is based on the Strategy holding a fixed number of position, unless Strategy Monitor generates closing signals, the built in PosSizer isn't generating any opening signals either.

I can't think of a good work around for generating closing Alerts given that Strategy Monitor only looks at the last bar. Unless I'm missing something, it is impossible to generate closing Alerts in Strategy Monitor, since SellAtMarket, etc. require a WealthLab.Position, which doesn't exist in Strategy Monitor. The best thing I can come up with is to write the open positions to a file, program the Strategy to only look at the symbols in the file to generate closing signals on the last bar, generate signals like ShortAtMarket instead of SellAtMarket, and then translate those signals into the real signals to email. Do you have any better ideas?

Obviously, Cone's suggestion of just running each Strategy is a much simpler solution. Do you know of any way to automate the running of Strategies in Wealth-Lab Pro, ie. run each Strategy at a particular time of day, every day as long as Wealth-Lab Pro is open?




profile picture

Panache

#7
UPDATE 02/07/2018: I would appreciate it if you could update the code in #7 to the following code which, among other improvements allows the user to automatically re-enter the log-in credentials again if required by Wealth-Lab Pro

Running each Strategy is a much better solution for me than using Strategy Monitor. To automate that, install AutoHotkey and create a script like this:

CODE:
Please log in to see this code.

You can modify the times depending on your preferences.

Create a Workspace in Wealth-Lab Pro named "Strategy Monitor" with the Strategies you want to have run every day. I suggest you make a blank Workspace your Default Workspace.

Make sure Schedule an Automatic Daily Update in Data Manager is checked. This AutoHotkey script is based on updating data at 9:00. If you prefer a different time to update your data, change the script accordingly.

Schedule the script to run at startup, and your data will be updated and then each of your Strategies will be run. The biggest advantage is that anything that can be done in a Strategy can be done to generate Alerts, including using all of the Position Sizers available in the Portfolio Simulation mode.
profile picture

Eugene

#8
Nice show Kurt, thanks for sharing. It never ceases to impress me how AHK or AutoIT can be integrated into a workflow and make one's life easier with just a handful of code lines. Glad you got it done on your own.
profile picture

Panache

#9
I thought I had it figured out. However, I'm running into a problem that the Strategies don't appear to run when I open my Strategy Monitor Workspace. The only tabs I get for each Strategy are Chart, Strategy Summary, Editor and Alerts. I get the same result if I click Editor>Run the Strategy for each Strategy in the Workspace, which seems very odd. I tried closing Wealth-Lab Pro and reopening it, and got the same result. Of course, if I open each Strategy manually, each of them runs as expected, even if it's a duplicate of a Strategy that is already open in the Workspace.

Obviously, I can make my AutoHotkey script open each Strategy, but that requires reprogramming the script every time I change the Strategies I want to monitor. Is there something in Wealth-Lab Pro that I can change to make each Strategy run when I open the Workspace?

When I restarted Wealth-Lab Pro, I got the message that I would have to log in within 5 days, which I did, so that is not the issue. However, it raised another concern. If I have Wealth-Lab Pro open, and my log in becomes obsolete, is the program going to stop functioning? If so, is there any way to find out when I am next going to have to log in (or to delete my current log in credentials) and re-log in ahead of time if I will be away at that time?
profile picture

Eugene

#10
Maybe the workspace is corrupt or something. I'd start by opening a new Workspace, reconfiguring Preferences > Performance visualizers, reopening each Strategy window and retesting. Also, make sure there's no compilation error in the Editor which prevents it from running or other specific that only you know at this point.

QUOTE:
If I have Wealth-Lab Pro open, and my log in becomes obsolete, is the program going to stop functioning?

Cone stressed it many times that one has to restart WLP every morning as part of the daily workflow. This should reset the counter but for the purpose of automation you would want to parse the message text anyway (AHK should support such basic task) and react accordingly.
profile picture

Panache

#11
QUOTE:
Maybe the workspace is corrupt or something
Apparently so. I deleted the Workspace and recreated it, and the problem is solved.

QUOTE:
you would want to parse the message text
Is there a way to delete my log-in credentials, so I can generate this message a couple of times this week to make sure my script is correct?
profile picture

Eugene

#12
That's good to know.
profile picture

Panache

#13
I would appreciate it if you could update the code in #7 to the following code which, among other improvements allows the user to automatically re-enter the log-in credentials again if required by Wealth-Lab Pro
CODE:
Please log in to see this code.
profile picture

Eugene

#14
Done.
profile picture

Panache

#15
Sorry. There is a bug in the code that I'm having trouble fixing.
profile picture

Panache

#16
Actually, it wasn't a bug -- I just had an older copy of the script running at the same time. Please note the change the last else if in post #13 to be < 100, instead of >2000, which will cause Wealth-Lab to reopen again and Strategy Monitor to run again at 20:05 and 20:10, respectively.

Eugene -- Instead of exposing my username and password in the AutoHotkey script, is there any problem with resetting my log-in information before I am going to be away, like this:
CODE:
Please log in to see this code.
profile picture

Eugene

#17
Not sure if it's okay for me to comment on such ideas here on the public forum as in your #16. I'm fine with whatever works for you Kurt.
profile picture

Panache

#18
I didn't know if you wanted me to post where the log-in is stored, and I didn't know if changing it more often than the default would cause any problems.