Description
Ichimoku Kinko Hyo indicator, smoothed by FIR filter.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Cloud("SenkouSpanA", "SenkouSpanB")]
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class mIchimokuFIR : Indicator
{
[Parameter("Fast Period (9)", DefaultValue = 9)]
public int inpPeriodFast { get; set; }
[Parameter("Medium Period (26)", DefaultValue = 26)]
public int inpPeriodMedium { get; set; }
[Parameter("Fast Period (52)", DefaultValue = 52)]
public int inpPeriodSlow { get; set; }
[Parameter("Chikou Displacement (26)", DefaultValue = 26)]
public int inpDisplacementChikou { get; set; }
[Parameter("CloudDisplacement (26)", DefaultValue = 26)]
public int inpDisplacementCloud { get; set; }
[Output("TenkanSen", LineColor = "Red")]
public IndicatorDataSeries outTenkanSen { get; set; }
[Output("Kijunsen", LineColor = "Blue")]
public IndicatorDataSeries outKijunSen { get; set; }
[Output("ChikouSpan", LineColor = "DarkViolet")]
public IndicatorDataSeries outChikouSpan { get; set; }
[Output("SenkouSpanA", LineColor = "Green", LineStyle = LineStyle.Dots)]
public IndicatorDataSeries outSenkouSpanA { get; set; }
[Output("SenkouSpanB", LineColor = "Red", LineStyle = LineStyle.Dots)]
public IndicatorDataSeries outSenkouSpanB { get; set; }
double maxfast, minfast, maxmedium, minmedium, maxslow, minslow;
private IndicatorDataSeries _firh;
private IndicatorDataSeries _firl;
private IndicatorDataSeries _firc;
protected override void Initialize()
{
_firh = CreateDataSeries();
_firl = CreateDataSeries();
_firc = CreateDataSeries();
}
public override void Calculate(int index)
{
if (index < 4)
{
_firh[index] = Bars.HighPrices[index];
_firl[index] = Bars.LowPrices[index];
_firc[index] = Bars.ClosePrices[index];
}
else
{
_firh[index] = (Bars.HighPrices[index] + 2.0 * Bars.HighPrices[index - 1] + 2.0 * Bars.HighPrices[index - 2] + Bars.HighPrices[index - 3]) / 6.0;
_firl[index] = (Bars.LowPrices[index] + 2.0 * Bars.LowPrices[index - 1] + 2.0 * Bars.LowPrices[index - 2] + Bars.LowPrices[index - 3]) / 6.0;
_firc[index] = (Bars.ClosePrices[index] + 2.0 * Bars.ClosePrices[index - 1] + 2.0 * Bars.ClosePrices[index - 2] + Bars.ClosePrices[index - 3]) / 6.0;
}
if ((index < inpPeriodFast) || (index < inpPeriodSlow))
return;
maxfast = _firh[index];
minfast = _firl[index];
maxmedium = _firh[index];
minmedium = _firl[index];
maxslow = _firh[index];
minslow = _firl[index];
for (int i = 0; i < inpPeriodFast; i++)
{
if (maxfast < _firh[index - i])
maxfast = _firh[index - i];
if (minfast > _firl[index - i])
minfast = _firl[index - i];
}
for (int i = 0; i < inpPeriodMedium; i++)
{
if (maxmedium < _firh[index - i])
maxmedium = _firh[index - i];
if (minmedium > _firl[index - i])
minmedium = _firl[index - i];
}
for (int i = 0; i < inpPeriodSlow; i++)
{
if (maxslow < _firh[index - i])
maxslow = _firh[index - i];
if (minslow > _firl[index - i])
minslow = _firl[index - i];
}
outTenkanSen[index] = (maxfast + minfast) / 2;
outKijunSen[index] = (maxmedium + minmedium) / 2;
outChikouSpan[index - inpDisplacementChikou] = _firc[index];
outSenkouSpanA[index + inpDisplacementCloud] = (outTenkanSen[index] + outKijunSen[index]) / 2;
outSenkouSpanB[index + inpDisplacementCloud] = (maxslow + minslow) / 2;
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mIchimokuFIR.algo
- Rating: 0
- Installs: 262
- Modified: 08/09/2022 19:28
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.