Signal alert message questions

Questions about MultiCharts and user contributed studies.
imoneyfish
Posts: 38
Joined: 26 Oct 2011
Has thanked: 6 times
Been thanked: 2 times

Signal alert message questions

Postby imoneyfish » 26 Jul 2012

Hi forum,

Can anybody give me a hand on the alert coding please. Struggling for a while now.
The idea is I want to get email alert when my signal open/close a position and if position hit stoploss and profittarget, it will also give me alert.

my code is below,

Code: Select all

if condition1 then
buy ( "Buyme" ) next bar at market ;



if condition2 then
sellshort ("Sellme") next bar at market ;


setstoploss(stoploss);
setprofittarget(profittarget);

if condition1 then alert("Long Position Opened");
if condition2 then alert("short position Opened");
end;
my question one is: how can I get alert message showing me position opened and the shares size has been opened/closed? I tried alert("Long Position Opened" + Shares); however, shares didn't work.

Question Two, How can i get a alert message tells me my stoploss or profittarget if they have been triggered?

Thanks a lot!

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Signal alert message questions

Postby Andrew MultiCharts » 27 Jul 2012

Try this example:

Code: Select all

[IntrabarOrderGeneration = true]

inputs: stoploss (100), profittarget (50);

vars: MP(0);

MP = MarketPosition_at_Broker;

If MP = 0 then alert (Text ("There is no open position"));

condition1 = MarketPosition = 0 and Close > Close[1];
condition2 = MarketPosition = 0 and Close < Close[1];

if condition1 then begin
alert (Text ("Buyme order is generated"));
buy ("Buyme") next bar at market;
end;

if condition2 then begin
alert (Text ("Sellme order is generated"));
sellshort ("Sellme") next bar at market;
end;

setstoploss(stoploss);
setprofittarget(profittarget);

If MP <> MP[1] and MP <> 0 then alert (Text ("Market Position has been opened. Current position is: ",
MarketPosition_at_broker, "Profit Tardget and Stop Loss orders are triggered"));

imoneyfish
Posts: 38
Joined: 26 Oct 2011
Has thanked: 6 times
Been thanked: 2 times

Re: Signal alert message questions

Postby imoneyfish » 05 Aug 2012

Try this example:

Code: Select all

[IntrabarOrderGeneration = true]

inputs: stoploss (100), profittarget (50);

vars: MP(0);

MP = MarketPosition_at_Broker;

If MP = 0 then alert (Text ("There is no open position"));

condition1 = MarketPosition = 0 and Close > Close[1];
condition2 = MarketPosition = 0 and Close < Close[1];

if condition1 then begin
alert (Text ("Buyme order is generated"));
buy ("Buyme") next bar at market;
end;

if condition2 then begin
alert (Text ("Sellme order is generated"));
sellshort ("Sellme") next bar at market;
end;

setstoploss(stoploss);
setprofittarget(profittarget);

If MP <> MP[1] and MP <> 0 then alert (Text ("Market Position has been opened. Current position is: ",
MarketPosition_at_broker, "Profit Tardget and Stop Loss orders are triggered"));

This code doesn't give me email notification when open position hit a stoplost or takeprofit level.

Mats
Posts: 8
Joined: 19 Mar 2012
Been thanked: 1 time

Re: Signal alert message questions

Postby Mats » 05 Aug 2012

You need to enable email alerts to get them, go to format.., alerts tab, check enable email alerts.

You also need to fill in the info for a mail server and most of the webmail sites will not work with multicharts. For instance, gmail and hotmail will not work. From the bunch I tried I got it to work best with aol.

You need to convert a number to text to use it in an alert e.g.
alert("Price is now = " + text( Close) );

To get an email that your stop or profit has triggered, you need to write some code that checks if instrument price is above/below stop/profit price and writes an alert. Don't forget to add something that checks that email will only be sent once. I do not think that there is an easier way but I could be wrong.

imoneyfish
Posts: 38
Joined: 26 Oct 2011
Has thanked: 6 times
Been thanked: 2 times

Re: Signal alert message questions

Postby imoneyfish » 06 Aug 2012

You need to enable email alerts to get them, go to format.., alerts tab, check enable email alerts.

You also need to fill in the info for a mail server and most of the webmail sites will not work with multicharts. For instance, gmail and hotmail will not work. From the bunch I tried I got it to work best with aol.

You need to convert a number to text to use it in an alert e.g.
alert("Price is now = " + text( Close) );

To get an email that your stop or profit has triggered, you need to write some code that checks if instrument price is above/below stop/profit price and writes an alert. Don't forget to add something that checks that email will only be sent once. I do not think that there is an easier way but I could be wrong.
Yes, you are right, the hardest part is get an email that when stop or profit has triggered. Anyone can help?

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Signal alert message questions

Postby Andrew MultiCharts » 16 Aug 2012

Yes, you are right, the hardest part is get an email that when stop or profit has triggered. Anyone can help?
By "triggered" do you mean an order is executed or an order is placed and remains active?

imoneyfish
Posts: 38
Joined: 26 Oct 2011
Has thanked: 6 times
Been thanked: 2 times

Re: Signal alert message questions

Postby imoneyfish » 16 Aug 2012

Yes, you are right, the hardest part is get an email that when stop or profit has triggered. Anyone can help?
By "triggered" do you mean an order is executed or an order is placed and remains active?
. When triggered I mean

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Signal alert message questions

Postby Andrew MultiCharts » 29 Aug 2012

You can put alert generation under the same condition as for order generation, as well as under market position at broker change criteria, but there may be some cases when a generated by script order is not placed at broker. In this case the only correct way to receive an alert is to find out if an order is placed at broker. Unfortunately one cannot find it out in EL script.


Return to “MultiCharts”