Check for absence of real time data

Questions about MultiCharts .NET and user contributed studies.
HPF
Posts: 47
Joined: 02 Apr 2013
Has thanked: 11 times
Been thanked: 7 times

Check for absence of real time data

Postby HPF » 06 May 2013

Hi,

In MultiCharts (with PowerLanguage), you have explained how to detect an interruption of the real time data feed:

viewtopic.php?f=16&t=11715

How do I accomplish the same in MultiCharts.Net ?

Thanks for your help,

HPF

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Check for absence of real time data

Postby Henry MultiСharts » 07 May 2013

Here is a sample code to check for absence of realtime data:

Code: Select all

using System;

namespace PowerLanguage.Strategy{
[IOGMode(IOGMode.Enabled)]

public class no_realtime_data_alert : SignalObject
{
public no_realtime_data_alert(object _ctx):base(_ctx)
{
}

public VariableSeries<Double> Counter;
protected override void Create()
{
Counter = new VariableSeries<double>(this, 0, 0, true);
}

protected override void StartCalc()
{
ExecControl.RecalcLastBarAfter(new TimeSpan(0, 0, 5));
}

DateTime LastCalcTime;
protected override void CalcBar()
{
LastCalcTime = DateTime.Now;
}

protected override void OnRecalcLastBarAfterEvent()
{
if (LastCalcTime < DateTime.Now.AddSeconds(-30))
Alerts.Alert("No realtime > 30 sec");

ExecControl.RecalcLastBarAfter(new TimeSpan(0, 0, 5));
}
}
}
Create a new signal, paste this code and compile it or import the attached pla file.
Once you add it to your chart make sure you have alerts enabled in Format->Strategy properties->Alerts tab. More info on the strategy alerts in the Wiki.
The code will generate an alert of the selected type intrabar if there is no realtime data for more than 30 seconds.

Image
Attachments
no_rt_alert_MC_Net.pln
(1.88 KiB) Downloaded 649 times


Return to “MultiCharts .NET”