Couldn't find anything using search. Is there a way of getting MC to send an email when it loses connectivity with the broker when running autotraded algos.?
[moderator's note]
another useful read on setting up email alert:
viewtopic.php?f=1&t=9906
see post #13
[FAQ]
viewtopic.php?f=16&t=6845
Email Alert -- Lost Connectivity
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Couldn't find anything using search. Is there a way of getting MC to send an email when it loses connectivity with the broker when running autotraded algos.?
Hello Momentum,
Unfortunately there is no way to detect broker / market data disconnection from EasyLanguage script, so that is not possible to make an alert on this condition.
Once the broker connection is lost->the auto trading turns off.
You can use “getappinfo” code word to check the auto trading status and then send an alert.
aiStrategyAuto - specifies return of a numerical value, indicating whether the calling application is using Automated Trade Execution GetAppInfo will return a value of 1 only if the calling application is using Automated Trade Execution, and a value of 0 in all other cases.
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
For such a helpful forum member, the answer can only be: "always".Any volunteer to code this detection?
That it would be something I'm myself am also interested in, is of course a nice bonus . Will report back later this weekend.
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
=============================================================
[moderator's update 20120419]
This post has been superseded.
From MC 8.0 onward, it's possible to code the Alert directly into the signal.
=============================================================
It's a shame that it isn't possible to trigger an Alert() in a Signal, since the GetAppInfo(aiStrategyAuto) doesn't work in indicators (only gives zeros). So, it's not possible to monitor the automated strategy "on" / "off" and generate a popup signal.
We'll probably need this PM for that: MC-319 - Allow Alert in Signals.
However, it's still possible to generate a sound alert or to write to a log or do something else. The first solution, using a sound alert, is the approach I've used in the code below. The sound alert tells you "ats turned off with no position" or tells "ats turned off with a open position":
Note: This is a Signal and not an indicator.
In the attached .zip file, there is the PowerLanguage file plus the two audio files that gets referenced in the code.
(PS: You'll need to manually change the directory where you place these sound files in the code)
Any feedback/suggestions more than welcomed.
[moderator's update 20120419]
This post has been superseded.
From MC 8.0 onward, it's possible to code the Alert directly into the signal.
=============================================================
It's a shame that it isn't possible to trigger an Alert() in a Signal, since the GetAppInfo(aiStrategyAuto) doesn't work in indicators (only gives zeros). So, it's not possible to monitor the automated strategy "on" / "off" and generate a popup signal.
We'll probably need this PM for that: MC-319 - Allow Alert in Signals.
However, it's still possible to generate a sound alert or to write to a log or do something else. The first solution, using a sound alert, is the approach I've used in the code below. The sound alert tells you "ats turned off with no position" or tells "ats turned off with a open position":
Code: Select all
{
ATS Status Monitor; monitors if the Autotrading strategy is turned off, and if yes, gives a sound alert
depending the strategy was turned off with an open position or not.
}
Inputs:
RecalcAfter(15);
Variables:
IntraBarPersist PrevATSStatus(0), // Holds the status of the ATS at the previous update
IntraBarPersist PrevMP(0), // Holds the previous MarketPosition
atsStatus(0), mp(0);
if (LastBarOnChart_s = True) then begin
atsStatus = GetAppInfo(aiStrategyAuto);
mp = MarketPosition(0) * CurrentContracts;
{ If your broker (IB, ZF, Pats) supports it, you might want to replace the line above with the
line below. However, keep in mind that:
"If Automated Trading was manually turned off by the user, the value returned
by the keyword stops changing, and may remain unequal to '0'." (Source: Helpfile)
mp = MarketPosition_at_Broker;
}
// If the current ATS Status differences from the previous, and the previous
// status was ON, give an alert
if (atsStatus <> PrevATSStatus) and (PrevATSStatus = 1) then begin
// If there was a MarketPosition on the previous update, we need to raise a big alarm
if (PrevMP <> 0) then
PlaySound("C:\Temp\atsOffWithOpenMP.wav")
// ... else a lighter alert would be needed
else
PlaySound("C:\Temp\atsOffNoMP.wav");
end;
PrevATSStatus = atsStatus;
PrevMP = mp;
RecalcLastBarAfter(RecalcAfter);
end; //: LastBarOnChart_s = True
In the attached .zip file, there is the PowerLanguage file plus the two audio files that gets referenced in the code.
(PS: You'll need to manually change the directory where you place these sound files in the code)
Any feedback/suggestions more than welcomed.
- Attachments
-
- atsStatusMonitor.zip
- (254.8 KiB) Downloaded 1409 times
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
Nice work, and fast too!It's a shame that it isn't possible to trigger an Alert() in a Signal, ...
Just a thought, can we use GV to bridge to an indicator?
[moderator's update 20120419]
From JoshM:
With MC 8.0 beta 2, it's also possible to code the Alert directly into the signal, so that the additional indicator isn't necessary any more:
Source: MC Blog
Alerts in Signals (Strategies)
There are now alerts available for signals (strategies). You can use sounds, visual or email alerts to get notified about orders and position changes. More info here -https://www.multicharts.com/pm/viewissue.php?issue_no=MC-319.
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Not a bad idea, since that does indeed work.Just a thought, can we use GV to bridge to an indicator?
By adding two lines in the signal (the GVSetNamedInt lines):
Code: Select all
{
ATS Status Monitor; monitors if the Autotrading strategy is turned off,
and if yes, gives a sound alert depending the strategy was turned off
with an open position or not.
}
Inputs:
RecalcAfter(15);
Variables:
IntraBarPersist PrevATSStatus(0), // Holds the status of the ATS at the previous update
IntraBarPersist PrevMP(0), // Holds the previous MarketPosition
atsStatus(0), mp(0);
if (LastBarOnChart_s = True) then begin
atsStatus = GetAppInfo(aiStrategyAuto);
mp = MarketPosition(0) * CurrentContracts;
{
If your broker (IB, ZF, Pats) supports it,
you might want to replace the line above with the
line below. However, keep in mind that:
"If Automated Trading was manually turned off by the user, the value returned
by the keyword stops changing, and may remain unequal to '0'." (Source: Helpfile)
mp = MarketPosition_at_Broker;
}
// If the current ATS Status differences from the previous, and the previous
// status was ON, give an alert
if (atsStatus <> PrevATSStatus) and (PrevATSStatus = 1) then begin
// If there was a MarketPosition on the previous update, we need to raise a big alarm
if (PrevMP <> 0) then begin
PlaySound("C:\Temp\atsOffWithOpenMP.wav");
value1 = GVSetNamedInt("atsStatusMonitor", 2);
// ... else a lighter alert would be needed
end else begin
PlaySound("C:\Temp\atsOffNoMP.wav");
value1 = GVSetNamedInt("atsStatusMonitor", 1);
end;
end;
PrevATSStatus = atsStatus;
PrevMP = mp;
RecalcLastBarAfter(RecalcAfter);
end; //: LastBarOnChart_s = True
Code: Select all
{
ATS Status Monitor Alerts indicator;
gives an alert if the ATS is turned off,
as detected by the ATS Status Monitor signal.
}
Inputs:
RecalcAfter(10);
Variables:
gvValue(0);
if (CheckAlert = True) then begin
gvValue = GVGetNamedInt("atsStatusMonitor", 0);
if (gvValue <> 0) then begin
if (gvValue = 1) then
Alert("ATS Status Monitor: ATS has been turned OFF, no position.");
if (gvValue = 2) then
Alert("ATS Status Monitor: ATS has been turned OFF with OPEN position.");
value1 = GVSetNamedInt("atsStatusMonitor", 0);
end;
RecalcLastBarAfter(RecalcAfter);
end;
Nice.
- Attachments
-
- scr.04-02-2012 17.49.03.png
- (4.79 KiB) Downloaded 8908 times
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
Bravo !
Amazing work Josh. I clicked "Thanks" 10 times!
Many thanks for your expertise in coding, your generosity in sharing, and your expediency in delivery!
Well done.
Amazing work Josh. I clicked "Thanks" 10 times!
Many thanks for your expertise in coding, your generosity in sharing, and your expediency in delivery!
Well done.
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Thanks TJ , you almost me make blush with all those kinds words.
Glad I could be of help.
Glad I could be of help.
Hi Josh,
Given that MC easylanguage is one big loop that gets iterated on each incoming tick, does the alerts work, given that the broker is disconnected, so no incoming ticks, so no loops so no alerts?
Neil.
P.S. It's the weekend so no incoming ticks for me to test on.
Given that MC easylanguage is one big loop that gets iterated on each incoming tick, does the alerts work, given that the broker is disconnected, so no incoming ticks, so no loops so no alerts?
Neil.
P.S. It's the weekend so no incoming ticks for me to test on.
- JoshM
- Posts: 2196
- Joined: May 20 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Yes Neil, both the indicator and the signal use RecalcLastBarAfter() for that.Hi Josh,
Given that MC easylanguage is one big loop that gets iterated on each incoming tick, does the alerts work, given that the broker is disconnected, so no incoming ticks, so no loops so no alerts?
Neil.
P.S. It's the weekend so no incoming ticks for me to test on.
If you can connect to your broker during the weekend (i.e. login into the order server), you can test it by connecting to the broker, turn automated trading on, and then turn it off. Even if the chart doesn't update (or isn't even a recent chart), after the specified 'RecalcAfter' seconds you should get the alert notifying that automated trading has been turned off.
Great work and great idea! Joshm you really are an asset here!
I'm curious if this is still the best way to notify us when there's a disconnect from our broker or data feed? The MC developers update the software so quickly that I'd like to keep on board with the current ways of doing things.
The reason why I'm posting this is because our server went down today (cyber attack) and when it came back up, Multicharts charts loaded up and signals were fired off as soon as this happened. So...
Issue:
1) I'd like to know when the server goes down
Answer:
1) We ping our server from an unrelated server constantly and send us an alert when our server isn't reached
Issue:
2) We have positions trading and the server goes down
Answer:
2) We log into our accounts on our local machines and monitor positions
Issue:
3) I'd like Multicharts to know when we have no connectivity and for it to shutoff SA/AA automatically
Answer:
??? I need some help with this one...
Thanks in advance for any light we can shed on this issue.
I'm curious if this is still the best way to notify us when there's a disconnect from our broker or data feed? The MC developers update the software so quickly that I'd like to keep on board with the current ways of doing things.
The reason why I'm posting this is because our server went down today (cyber attack) and when it came back up, Multicharts charts loaded up and signals were fired off as soon as this happened. So...
Issue:
1) I'd like to know when the server goes down
Answer:
1) We ping our server from an unrelated server constantly and send us an alert when our server isn't reached
Issue:
2) We have positions trading and the server goes down
Answer:
2) We log into our accounts on our local machines and monitor positions
Issue:
3) I'd like Multicharts to know when we have no connectivity and for it to shutoff SA/AA automatically
Answer:
??? I need some help with this one...
Thanks in advance for any light we can shed on this issue.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
MAtricks, which broker profile do you use for auto trading?Issue:
3) I'd like Multicharts to know when we have no connectivity and for it to shutoff SA/AA automatically
Answer:
??? I need some help with this one...
Thanks in advance for any light we can shed on this issue.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
There are no particular "broker/data connection is lost" events/reserved words in PowerLanguage at the moment. The "broker profile is disconnected" event can be received only by checking the auto trading status, as for some brokers AT is turned off if the broker connection was lost and was not restored.I use Rithmic for my live trading.
When Rithmic broker profile looses the connection - MultiCharts automatically tries to reconnect to it infinitely. It means Rithmic broker profile is never turned into “Disconnected” state and the auto trading is never turned off.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
AT can be turned off from the code with the help of ".at_toggle" command.It would be great if we had enough control to turn off autotrading completely from our code.
Am I right in saying that turning off AT (either manually or automatically from within the script) results in...AT can be turned off from the code with the help of .... ".at_toggle" command[/url].It would be great if we had enough control to turn off autotrading completely from our code.
1. The strategy recalculating against all of the data currently loaded on the chart when AT is turned back on before it can place any further trades? Depending on the amount of Data and Studies, that could take a significant amount of time.
2. If turned off from the Status Bar, ALL strategies placed on that chart will be turned off?
If so, is there a way to keep the strategy 'on' but have the code bypassed on each tick based on a user-configurable toggle or button - either manually or via the script?
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
That is correct. When a strategy/signal script is recalculatedAm I right in saying that turning off AT (either manually or automatically from within the script) results in...
1. The strategy recalculating against all of the data currently loaded on the chart when AT is turned back on before it can place any further trades? Depending on the amount of Data and Studies, that could take a significant amount of time.
All signals applied to a chart = one strategy. Auto trading is turned on/off for the complete strategy, not for individual signals. Individual signals can be turned off to be excluded from the strategy prior to turning on the auto trading.2. If turned off from the Status Bar, ALL strategies placed on that chart will be turned off?
What is your final goal?If so, is there a way to keep the strategy 'on' but have the code bypassed on each tick based on a user-configurable toggle or button - either manually or via the script?
Currently, there is only one Automate Trading Switch on a chart. This switch affects all the signals for that chart.What is your final goal?
Ideally, it would be possible to assign signals/strategies to their own on/off button on a toolbar or dashboard. That would enable signals to be turned on or off without having to select 'Format Signals' - then change the Status of the signals - before being able to press the Automate Trading Switch whenever you wanted to change the signal(s) to execute.
As far as I can determine, the only way to achieve this now is to assign each signal to its own chart which unnecessarily requires duplicated Instruments and Indicators.
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
At the moment there is no way to do that.Currently, there is only one Automate Trading Switch on a chart. This switch affects all the signals for that chart.
Ideally, it would be possible to assign signals/strategies to their own on/off button on a toolbar or dashboard. That would enable signals to be turned on or off without having to select 'Format Signals' - then change the Status of the signals - before being able to press the Automate Trading Switch whenever you wanted to change the signal(s) to execute.
-
- Posts: 4
- Joined: Mar 03 2015
Have anyone gotten the built in Email alert system to work as there is a way via Bulksms.com to convert an email sent to a specific mailbox with a certain code in the subject header into an sms to a predefined cell nr..this could be very handy indeed??
Is their any way in MC to create an basic email alert where one can specify the subject matter and the address etc, just very basic and then make use of the SMTP settings in the alert window..??
Is their any way in MC to create an basic email alert where one can specify the subject matter and the address etc, just very basic and then make use of the SMTP settings in the alert window..??
Hi
Not sure what you are looking for however this is the subject line (see below) of the email alert I can get from MC using the MC (PowerLanguage) code that I have built into one of my indicators.. ,there is limited editing of the alert message to reduce the length of the subject line but it is limited.
MultiCharts64 Alert: RenkoSys2_GV_V1 generated 'DA6M15:0.00030 From C To B' at 0.7675 on DA6M15 (3 Tick Bars)
This alert tells me what chart and what indicator is sending the alert, and what Instrument, plus the reason for the alert to go off (e.g. "from C to B") and the last price of the instrument.
I get this sent to my mobile as an email. Is this what you are looking for?
Not sure what you are looking for however this is the subject line (see below) of the email alert I can get from MC using the MC (PowerLanguage) code that I have built into one of my indicators.. ,there is limited editing of the alert message to reduce the length of the subject line but it is limited.
MultiCharts64 Alert: RenkoSys2_GV_V1 generated 'DA6M15:0.00030 From C To B' at 0.7675 on DA6M15 (3 Tick Bars)
This alert tells me what chart and what indicator is sending the alert, and what Instrument, plus the reason for the alert to go off (e.g. "from C to B") and the last price of the instrument.
I get this sent to my mobile as an email. Is this what you are looking for?
I don't use my power of thread resurrection often, but this may be a good time for it.
The method proposed ITT to detect a disconnection doesn't work for me in 2018. I tested by manually disconnecting from IB API. No alert, because my signal still prints getappinfo(aistrategyauto)=1 after the disconnection. (The signal continues calculating because my broker is not my data provider.)
Are there any other ways for a signal to detect a disconnection from the broker?
The method proposed ITT to detect a disconnection doesn't work for me in 2018. I tested by manually disconnecting from IB API. No alert, because my signal still prints getappinfo(aistrategyauto)=1 after the disconnection. (The signal continues calculating because my broker is not my data provider.)
Are there any other ways for a signal to detect a disconnection from the broker?
- TJ
- Posts: 7775
- Joined: Aug 29 2006
- Location: Global Citizen
- Has thanked: 1036 times
- Been thanked: 2233 times
I don't use my power of thread resurrection often, but this may be a good time for it.
The method proposed ITT to detect a disconnection doesn't work for me in 2018. I tested by manually disconnecting from IB API. No alert, because my signal still prints getappinfo(aistrategyauto)=1 after the disconnection. (The signal continues calculating because my broker is not my data provider.)
Are there any other ways for a signal to detect a disconnection from the broker?
Open a chart with IB and put this indicator on it.