Could not send real-time buy alerts via email
Author: tomphm
Creation Date: 9/9/2014 3:52 PM
profile picture

tomphm

#1
Eugene,

Below is the code that have trouble with send out real-time buy alerts via email within the Strategy Monitor window. Thank you.

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

Cone

#2
This code will never send out a real time alert because the statement "if (BuyAtLimit..." will always be null for an Alert. A trading signal cannot return a Position object for an Alert because a Position cannot be created (in the future). On the other hand, your code should send emails for all historical positions created.

To fix it, do this instead.
CODE:
Please log in to see this code.

I'm not sure why you'd want to get an Alert by email for this type of Strategy, but there you have it.

You can also use the built-in Email Alert function in the Strategy Monitor if you properly set up your Email Settings in Preferences (F12).
profile picture

tomphm

#3
Thank you Cone. Interesting problem and solution. I think you are saying that the return Position object from "if(BuyAtLimit.." is only valid for historical data. In the case of where the bar is in real-time, it is not valid. That's true that the code I listed worked fine for historical data.

In addition to test for the last bar, it need also to check that a "BuyAtLimit" did occurred before sending the alert email - is this correct? Do you have any suggestions on this?

I need a real-time alert signal on this strategy so that I can place a real order.

I have attempted to set up the email settings in the Preferences menu (F12), however, for unknown reasons, WL keep crashing on me.

Thanks.
profile picture

Eugene

#4
QUOTE:
In addition to test for the last bar, it need also to check that a "BuyAtLimit" did occurred before sending the alert email - is this correct? Do you have any suggestions on this?

Sure. After the main (trading) loop, you could access the Alerts collection and loop by the triggered alerts. There are several suitable examples in the QuickRef > "Alert Object" section.

QUOTE:
I have attempted to set up the email settings in the Preferences menu (F12), however, for unknown reasons, WL keep crashing on me.

The reason is known: your email settings appear to be incorrect. This causes the long-standing crash that, unfortunately, still isn't fixed: (90180) Email Unhandled Exceptions Crash WL 6.4. Although it will not crash on you unlike WL, SendEmail might also have trouble sending out with given parameters.

Instead of XXX@yahoo.com and Yahoo in general, give both WLP and SendEmail a try using a different email account this time.
profile picture

tomphm

#5
Thank you Eugene for pointing out about the alerts properties. I will try to get the email working.

I just set up email settings in Preferences menu and was able to get trade alerts send out via email using the Auto-Email button on the Strategy Monitor window. After a few minutes, WLP crashed. Not sure if some buffers somewhere might be overloaded because of a large number of alerts being generated and sent out or due to something else.

I have not heard about SendEmail but will check it out. Thank you.

profile picture

Eugene

#6
QUOTE:
I have not heard about SendEmail but will check it out. Thank you.

SendEmail is the short for param.SendEmail in your code.
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).