-
Notifications
You must be signed in to change notification settings - Fork 6
Show Popup
Trigger First Alert
After you installed the library on your cTrader indicator/cBot you will be able to show the popup by calling "Notifications.ShowPopup" method but before that, you have to first change the "AccessRights" of your indicator/cBot to "AccessRights.FullAccess" and then add the "cAlgo.API.Alert" using on top of your indicator/cBot code:
using cAlgo.API.Alert;
Then call the "ShowPopup" method on your code:
Notifications.ShowPopup(MarketSeries.TimeFrame, Symbol, Symbol.Bid, "AlertTest Indicator", TradeType.Sell, "No comment", Server.Time);
You don't have to care about the time zone, the user will be able to set the time zone on popup settings.
And you will see this:
The user will be able to change the popup theme and accent.
Full Working Indicator Sample
using cAlgo.API;
using cAlgo.API.Alert;
using System;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class AlertTest : Indicator
{
private int _barIndex;
protected override void Initialize()
{
}
public override void Calculate(int index)
{
if (_barIndex != index && IsLastBar)
{
_barIndex = index;
TradeType tradeType = MarketSeries.Close[index - 1] > MarketSeries.Open[index - 1] ? TradeType.Buy : TradeType.Sell;
Notifications.ShowPopup(MarketSeries.TimeFrame, Symbol, Symbol.Bid, "AlertTest Indicator", tradeType, "No comment", Server.Time);
}
}
}
}
using cAlgo.API;
using cAlgo.API.Alert;
using System;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class AlertTester : Robot
{
private int _barIndex;
protected override void OnStart()
{
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnBar()
{
int index = MarketSeries.Close.Count - 1;
if (_barIndex != index)
{
_barIndex = index;
TradeType tradeType = MarketSeries.Close[index - 1] > MarketSeries.Open[index - 1] ? TradeType.Buy : TradeType.Sell;
Notifications.ShowPopup(MarketSeries.TimeFrame, Symbol, Symbol.Bid, "AlertTest cBot", tradeType, "No comment", Server.Time);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}