Profile Disconnection Alert

Questions about MultiCharts .NET and user contributed studies.
stephenfsams
Posts: 2
Joined: 27 Sep 2017
Has thanked: 1 time

Profile Disconnection Alert

Postby stephenfsams » 27 Jan 2018

Hi,

I'd like to get an alert (pop up, email, etc.) when a broker profile is disconnected between certain hours of the day (like 2am to 8am).

I wrote the following strategy, but I think it will only run when applied to a chart when new bars are painting (i.e. when the symbol's market is open).

Is there a way to check and alert more effectively in MultiCharts .net 11?

Stephen

Code: Select all

using ATCenterProxy.interop;

namespace PowerLanguage.Strategy
{
public class __S__Connection : SignalObject
{
public __S__Connection(object _ctx) : base(_ctx) {}

protected override void CalcBar()
{
//check profile connection and send alert
foreach(var profile in TradeManager.TradingProfiles)
if (profile.Name.Equals(Profile) &&
profile.ConnectionState != ETM_ConnectionChanged.eTM_CC_Connected
/* && hours between x and y */)
{
Alerts.Alert("{0} {1}", profile.Name, profile.ConnectionState);
break;
}
}
}
}

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Profile Disconnection Alert

Postby Svetlana MultiCharts » 08 Feb 2018

Hello, stephenfsams,

This script shall be added not in “CalcBar” method, but in the event handler of a timer.
Also it’s necessary to add “TradeManager.ProcessEvents();”.
You can use “ExecControl.RecalcLastBarAfter” as a timer, and
“OnRecalcLastBarAfterEvent()” as an event handler.


Return to “MultiCharts .NET”