Threading and MessageBox?
Author: heech
Creation Date: 10/29/2008 3:14 PM
profile picture

heech

#1
Hi,

I'd like a way to interactively alert the user of certain events in the strategy, beyond printing to debug. I'm very new to .NET, and don't know the best way of going about this.

Looking at a sample, I saw System.Windows.Forms.MessageBox.Show(). This gives me the result I want... but it's non-modal, and during back-testing, execution froze until I clicked "okay" to clear the window.

If I have multiple strategies in the strategy monitor and MessageBox.Show() is called, will that also freeze other strategies? Is there a better, simple one-line call for this kind of an alert message?

Much thanks.
profile picture

Eugene

#2
Using search, the following existing discussions could be found:

WL5 : Showing a Windows Form from a strategy script
new Thread from strategy
profile picture

heech

#3
Eugene,

Search is where I headed first, but isn't working for me. It shows it as "under maintenance". Appreciate the links!
profile picture

DaveAronow

#4
The following code will create a non-modal window but then will leave the window visible when the script finishes (using the ShowDialog() method). If you remove that the window will vanish when the script completes and the AppDomain is removed from memory. Just curious why you wouldn't want to use the printdebug method though?

Dave

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

heech

#5
Dave,

I'm looking for some way to send myself *actual* alerts from the script as it runs in the Strategy Monitor, not just while back-testing. While back-testing, the debug window is fine/great.

Do you know if your suggestion will work from the Strategy Monitor..? And/or, is there something I'm missing, in terms of a really easy mechanisms to send information out of active strategies running in the Monitor?
profile picture

Eugene

#6
QUOTE:
And/or, is there something I'm missing, in terms of a really easy mechanisms to send information out of active strategies running in the Monitor?

You could, for instance, e-mail it.
profile picture

DaveAronow

#7
Another option is using Win32 messages. You'd need to use PInvoke to call them but you could call FindWindow to get the window handle of a notepad instance (or a WL window for that matter), then send text to the window. You could also use email as Eugene suggested, or also write to a database and poll the DB for changes (or if it's sql 2005 you can have the database itself notify you via a callback).

Dave
profile picture

heech

#8
Oh Eugene, that's too cool. Thank you.

How about AlertBySMS? :)
profile picture

heech

#9
Nice tools at that link. CommentaryWindow should also do the trick, yes?

Is there a way to link in this code to my strategy with its existing namespace, or should I just copy/paste code into that single file?

Pardon all the silly questions, my universe of knowledge of Wealth-Lab is less than 48 hours old. :)
profile picture

Eugene

#10
QUOTE:
Is there a way to link in this code to my strategy with its existing namespace, or should I just copy/paste code into that single file?

In the future, when we have enough stuff to compile the Community.Components.dll with that procedure, you'll need to drop that assembly in Wealth-Lab's main directory, reference it in every Strategy, and then call the procedure. Meanwhile it's possible to insert the procedure into a Strategy manually.
profile picture

Eugene

#11
The Community.Components Extension is finally arrived and now includes the revamped AlertByEmail.

Re: AlertBySMS
By the way, if your mobile phone number's got an e-mail attached, it's certainly possible to send alerts directly:

Carrier-provided Email or Web to SMS gateways
profile picture

jalalfeghhi1

#12
Eugene,
I have been researching sending SMS to my mobile phone from within my strategy code. I found this article but it is more than 2 years old. Could you please update me on the latest, how can I send sms to my cell phone? I did not find any extensions for this purpose.

-Best J
profile picture

Eugene

#13
Ask your operator about the phone's email address.

Then either simply configure your mailbox in Wealth-Lab's Preferences > Email Settings to receive Alerts or use the AlertByEmail function which description can be found in the Wiki.

profile picture

jalalfeghhi1

#14
Eugene,
Thanks. Is the procedure to send emails is the same as SMS? I am concerned with sending SMS (text messages) to my phone, not emails.

-Regards, J
profile picture

Eugene

#15
If your operator provides an email to SMS gateway, the email sent will be SMSed to your phone.

Check out the Wikipedia link above, it's all explained there.
profile picture

jalalfeghhi1

#16
Eugene, I think I understand now, thanks :-)
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).