Alert for indicator
31 Jul 2020, 13:22
Alert for indicator: This indicator does not send alert to my email address in the ctrader platform, please can you help with the settings to be able to receive email alert.
Replies
onyiaegwu.nduka
31 Jul 2020, 14:35
RE:
PanagiotisCharalampous said:
Hi onyiaegwu.nduka,
Which indicator? Can you post the code?
Best Regards,
Panagiotis
Below is the code:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
using System.Net;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.Internet)]
public class AlertForIndicator : Indicator
{
[Parameter("Fast Line", Group = "Source")]
public DataSeries Fast { get; set; }
[Parameter("Slow Line", Group = "Source")]
public DataSeries Slow { get; set; }
[Parameter("Long Signal", Group = "Signal", DefaultValue = false)]
public bool Long { get; set; }
[Parameter("Short Signal", Group = "Signal", DefaultValue = false)]
public bool Short { get; set; }
[Parameter("Arrow on Chart", Group = "Signal", DefaultValue = true)]
public bool Arrow { get; set; }
[Parameter("Backtest", Group = "Signal", DefaultValue = false)]
public bool Bckt { get; set; }
[Parameter("Email", Group = "Notification", DefaultValue = false)]
public bool SendEmail { get; set; }
[Parameter("Telegram", Group = "Notification")]
public bool SendTelegram { get; set; }
[Parameter("Sound ON", Group = "Notification", DefaultValue = true)]
public bool PlaySound { get; set; }
[Parameter("Media File Location", Group = "Notification", DefaultValue = "c:\\windows\\media\\Alarm01.Wav")]
public string MediaFile { get; set; }
[Parameter("From", Group = "Email", DefaultValue = "from@example.com")]
public string Sender { get; set; }
[Parameter("To", Group = "Email", DefaultValue = "to@example.com")]
public string Receiver { get; set; }
[Parameter("Subject", Group = "Email", DefaultValue = "my subject")]
public string Subject { get; set; }
[Parameter("Message", Group = "Email", DefaultValue = "")]
public string EmailBody { get; set; }
[Parameter("ChatId", Group = "Telegram", DefaultValue = "")]
public string ChatId { get; set; }
[Parameter("Token", Group = "Telegram", DefaultValue = "")]
public string BotToken { get; set; }
[Parameter("Cross Up Color", Group = "Colors", DefaultValue = "Lime")]
public string ColorArrowUP { get; set; }
[Parameter("Cross Down Color", Group = "Colors", DefaultValue = "Orange")]
public string ColorArrowDW { get; set; }
string TelgramURL;
protected override void Initialize()
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
TelgramURL = string.Format("https://api.telegram.org/bot{0}/sendMessage?chat_id={1}&text=", BotToken, ChatId);
}
int LastBar = 0;
public override void Calculate(int index)
{
if (index <= LastBar)
return;
LastBar = index;
string message = Symbol.Name + "\n" + Symbol.Bid + "\n" + TimeFrame;
if (Long && Fast.HasCrossedAbove(Slow, 0))
{
if (PlaySound)
Notifications.PlaySound(MediaFile);
if (SendEmail)
Notifications.SendEmail(Sender, Receiver, Subject, EmailBody + " " + message + " " + "Cross Long Signal");
if (Arrow)
Chart.DrawIcon(Bckt ? "Up" + index : "Up", ChartIconType.UpArrow, index, Bars[LastBar - 5].Low, Color.FromName(ColorArrowUP));
if (SendTelegram)
SendMessage(message + "\n" + "Cross Long Signal" + "\n" + EmailBody);
}
else if (Short && Fast.HasCrossedBelow(Slow, 0))
{
if (PlaySound)
Notifications.PlaySound(MediaFile);
if (SendEmail)
Notifications.SendEmail(Sender, Receiver, Subject, EmailBody + " " + message + " " + "Cross Short Signal");
if (Arrow)
Chart.DrawIcon(Bckt ? "Down" + index : "Down", ChartIconType.DownArrow, index, Bars[LastBar - 5].High, Color.FromName(ColorArrowDW));
if (SendTelegram)
SendMessage(message + "\n" + "Cross Short Signal" + "\n" + EmailBody);
}
}
void SendMessage(string s)
{
var request = WebRequest.Create(TelgramURL + s);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
var response = request.GetResponse();
}
}
}
@onyiaegwu.nduka
PanagiotisCharalampous
31 Jul 2020, 14:42
Hi onyiaegwu.nduka,
Go to Settings > Email and make sure your settings are correct.

Best Regards,
Panagiotis
@PanagiotisCharalampous
chemchehe
25 Nov 2020, 11:53
( Updated at: 21 Dec 2023, 09:22 )
RE:
Hi, this indicator does not reload itself after a chart is refreshed. I would appreciate if you could help with this fix given that I am not a coder. Thanks.
Hi onyiaegwu.nduka,
Go to Settings > Email and make sure your settings are correct.
Best Regards,
Panagiotis
@chemchehe


PanagiotisCharalampous
31 Jul 2020, 13:36
Hi onyiaegwu.nduka,
Which indicator? Can you post the code?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous