Create an allert for the Ichimoku kinku hyo indicator
Create an allert for the Ichimoku kinku hyo indicator
12 May 2022, 17:46
hi . Who can help me?
I would like to add a code to the Ichimoku Kinko Hyo Indicator that gives SOUND & GMAIL ALLERT in all time frame , under the following conditions:
1- Bullish cross in which Tenkansen Creates high but Kijunsen loses high.
2. bearish cross in which Tenkensen Creates Low but Kijunsen loses low.
*bullish cross :
*bearish cross :
The Ichimoku indicator code is below:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class IchimokuKinkoHyo : Indicator
{
[Parameter(DefaultValue = 9)]
public int periodFast { get; set; }
[Parameter(DefaultValue = 26)]
public int periodMedium { get; set; }
[Parameter(DefaultValue = 52)]
public int periodSlow { get; set; }
[Parameter(DefaultValue = 26)]
public int DisplacementChikou { get; set; }
[Parameter(DefaultValue = 26)]
public int DisplacementCloud { get; set; }
[Output("TenkanSen", Color = Colors.Red)]
public IndicatorDataSeries TenkanSen { get; set; }
[Output("Kijunsen", Color = Colors.Blue)]
public IndicatorDataSeries KijunSen { get; set; }
[Output("ChikouSpan", Color = Colors.DarkViolet)]
public IndicatorDataSeries ChikouSpan { get; set; }
[Output("SenkouSpanB", Color = Colors.Red, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries SenkouSpanB { get; set; }
[Output("SenkouSpanA", Color = Colors.Green, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries SenkouSpanA { get; set; }
private double maxfast, minfast, maxmedium, minmedium, maxslow, minslow;
public override void Calculate(int index)
{
if ((index < periodFast) || (index < periodSlow)) { return; }
maxfast = MarketSeries.High[index];
minfast = MarketSeries.Low[index];
maxmedium = MarketSeries.High[index];
minmedium = MarketSeries.Low[index];
maxslow = MarketSeries.High[index];
minslow = MarketSeries.Low[index];
for (int i = 0; i < periodFast; i++)
{
if (maxfast < MarketSeries.High[index - i]) { maxfast = MarketSeries.High[index - i]; }
if (minfast > MarketSeries.Low[index - i]) { minfast = MarketSeries.Low[index - i]; }
}
for (int i = 0; i < periodMedium; i++)
{
if (maxmedium < MarketSeries.High[index - i]) { maxmedium = MarketSeries.High[index - i]; }
if (minmedium > MarketSeries.Low[index - i]) { minmedium = MarketSeries.Low[index - i]; }
}
for (int i = 0; i < periodSlow; i++)
{
if (maxslow < MarketSeries.High[index - i]) { maxslow = MarketSeries.High[index - i]; }
if (minslow > MarketSeries.Low[index - i]) { minslow = MarketSeries.Low[index - i]; }
}
TenkanSen[index] = (maxfast + minfast) / 2;
KijunSen[index] = (maxmedium + minmedium) / 2;
ChikouSpan[index - DisplacementChikou] = MarketSeries.Close[index];
SenkouSpanA[index + DisplacementCloud] = (TenkanSen[index] + KijunSen[index]) / 2;
SenkouSpanB[index + DisplacementCloud] = (maxslow + minslow) / 2;
}
}
}
Replies
safaeianmohsen
18 Jun 2022, 08:04
( Updated at: 18 Jun 2022, 08:06 )
RE: no allert
hi dear ahmad . I ran the code and it was active on the chart for a long time. Unfortunately, no sound allert was received at the target points. What is the problem? Do I have to make certain settings in C Trader to receive the sound alarm?
Hi,
Try this:
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = true, AccessRights = AccessRights.None)] public class IchimokuKinkoHyo : Indicator { private int _lastAlertBar; [Parameter(DefaultValue = 9)] public int periodFast { get; set; } [Parameter(DefaultValue = 26)] public int periodMedium { get; set; } [Parameter(DefaultValue = 52)] public int periodSlow { get; set; } [Parameter(DefaultValue = 26)] public int DisplacementChikou { get; set; } [Parameter(DefaultValue = 26)] public int DisplacementCloud { get; set; } [Parameter("Enable", DefaultValue = true, Group = "Alert")] public bool IsAlertEnabled { get; set; } [Parameter("Sound File Path", Group = "Alert")] public string SoundFilePath { get; set; } [Parameter("From Email", Group = "Alert")] public string FromEmail { get; set; } [Parameter("To Email", Group = "Alert")] public string ToEmail { get; set; } [Output("TenkanSen", Color = Colors.Red)] public IndicatorDataSeries TenkanSen { get; set; } [Output("Kijunsen", Color = Colors.Blue)] public IndicatorDataSeries KijunSen { get; set; } [Output("ChikouSpan", Color = Colors.DarkViolet)] public IndicatorDataSeries ChikouSpan { get; set; } [Output("SenkouSpanB", Color = Colors.Red, LineStyle = LineStyle.Lines)] public IndicatorDataSeries SenkouSpanB { get; set; } [Output("SenkouSpanA", Color = Colors.Green, LineStyle = LineStyle.Lines)] public IndicatorDataSeries SenkouSpanA { get; set; } private double maxfast, minfast, maxmedium, minmedium, maxslow, minslow; public override void Calculate(int index) { if ((index < periodFast) || (index < periodSlow)) { return; } maxfast = MarketSeries.High[index]; minfast = MarketSeries.Low[index]; maxmedium = MarketSeries.High[index]; minmedium = MarketSeries.Low[index]; maxslow = MarketSeries.High[index]; minslow = MarketSeries.Low[index]; for (int i = 0; i < periodFast; i++) { if (maxfast < MarketSeries.High[index - i]) { maxfast = MarketSeries.High[index - i]; } if (minfast > MarketSeries.Low[index - i]) { minfast = MarketSeries.Low[index - i]; } } for (int i = 0; i < periodMedium; i++) { if (maxmedium < MarketSeries.High[index - i]) { maxmedium = MarketSeries.High[index - i]; } if (minmedium > MarketSeries.Low[index - i]) { minmedium = MarketSeries.Low[index - i]; } } for (int i = 0; i < periodSlow; i++) { if (maxslow < MarketSeries.High[index - i]) { maxslow = MarketSeries.High[index - i]; } if (minslow > MarketSeries.Low[index - i]) { minslow = MarketSeries.Low[index - i]; } } TenkanSen[index] = (maxfast + minfast) / 2; KijunSen[index] = (maxmedium + minmedium) / 2; ChikouSpan[index - DisplacementChikou] = MarketSeries.Close[index]; SenkouSpanA[index + DisplacementCloud] = (TenkanSen[index] + KijunSen[index]) / 2; SenkouSpanB[index + DisplacementCloud] = (maxslow + minslow) / 2; if (IsLastBar && IsAlertEnabled && _lastAlertBar != index) { _lastAlertBar = index; if (TenkanSen.HasCrossedAbove(KijunSen, 0)) { Notifications.PlaySound(SoundFilePath); Notifications.SendEmail(FromEmail, ToEmail, "Ichimoku kinku hyo Alert | Bullish", "TenkanSen crossed above KijunSen"); } else if (TenkanSen.HasCrossedBelow(KijunSen, 0)) { Notifications.PlaySound(SoundFilePath); Notifications.SendEmail(FromEmail, ToEmail, "Ichimoku kinku hyo Alert | Bearish", "TenkanSen crossed below KijunSen"); } } } } }
For email notification to work you have to first configure your cTrader email notification settings.
@safaeianmohsen
amusleh
13 May 2022, 10:32
Hi,
Try this:
For email notification to work you have to first configure your cTrader email notification settings.
@amusleh