problem with 4.2(aw ichimoku indicator)
Created at 28 May 2022, 14:17
problem with 4.2(aw ichimoku indicator)
28 May 2022, 14:17
this code work in 4.1 but doesn't work correctly in 4.2. i couldn't resolve that.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
[Cloud("Up Kumo", "Down Kumo", Opacity = 0.2)]
public class AwIchimoku : Indicator
{
[Parameter("Tenkan sen", DefaultValue = 9, MinValue = 1)]
public int Ten_Period { get; set; }
[Parameter("Kijun sen", DefaultValue = 26, MinValue = 1)]
public int K_Period { get; set; }
[Parameter("Senkou span B", DefaultValue = 52, MinValue = 1)]
public int SB_Period { get; set; }
[Output("Tenkan sen", LineStyle = LineStyle.Solid, LineColor = "Red")]
public IndicatorDataSeries Ten_Result { get; set; }
[Output("Kijun sen", LineStyle = LineStyle.Solid, LineColor = "Blue")]
public IndicatorDataSeries K_Result { get; set; }
[Output("Chiku span", LineStyle = LineStyle.Solid, LineColor = "Purple")]
public IndicatorDataSeries C_Result { get; set; }
[Output("Up Kumo", LineStyle = LineStyle.Solid, LineColor = "Green")]
public IndicatorDataSeries Up_Result { get; set; }
[Output("Down Kumo", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")]
public IndicatorDataSeries Down_Result { get; set; }
[Output("Span A", LineStyle = LineStyle.Solid, LineColor = "Green")]
public IndicatorDataSeries SA_Result { get; set; }
[Output("Span B", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")]
public IndicatorDataSeries SB_Result { get; set; }
private IchimokuKinkoHyo _ICHI;
protected override void Initialize()
{
_ICHI = Indicators.IchimokuKinkoHyo(Ten_Period, K_Period, SB_Period);
}
public override void Calculate(int index)
{
Ten_Result[index] = _ICHI.TenkanSen.Last(0);
K_Result[index] = _ICHI.KijunSen.Last(0);
C_Result[index - 26] = _ICHI.ChikouSpan.Last(0);
SA_Result[index + 26] = (_ICHI.TenkanSen.Last(0) + _ICHI.KijunSen.Last(0)) / 2;
SB_Result[index + 26] = _ICHI.SenkouSpanB.Last(0);
Up_Result[index + 26] = (_ICHI.TenkanSen.Last(0) + _ICHI.KijunSen.Last(0)) / 2;
Down_Result[index + 26] = _ICHI.SenkouSpanB.Last(0);
}
}
}
Replies
IRCtrader
30 May 2022, 18:47
RE:
amusleh said:
Hi,
Try this:
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, AccessRights = AccessRights.None)] [Cloud("Up Kumo", "Down Kumo", Opacity = 0.2)] public class AwIchimoku : Indicator { [Parameter("Tenkan sen", DefaultValue = 9, MinValue = 1)] public int Ten_Period { get; set; } [Parameter("Kijun sen", DefaultValue = 26, MinValue = 1)] public int K_Period { get; set; } [Parameter("Senkou span B", DefaultValue = 52, MinValue = 1)] public int SB_Period { get; set; } [Output("Tenkan sen", LineStyle = LineStyle.Solid, LineColor = "Red")] public IndicatorDataSeries Ten_Result { get; set; } [Output("Kijun sen", LineStyle = LineStyle.Solid, LineColor = "Blue")] public IndicatorDataSeries K_Result { get; set; } [Output("Chiku span", LineStyle = LineStyle.Solid, LineColor = "Purple")] public IndicatorDataSeries C_Result { get; set; } [Output("Up Kumo", LineStyle = LineStyle.Solid, LineColor = "Green")] public IndicatorDataSeries Up_Result { get; set; } [Output("Down Kumo", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")] public IndicatorDataSeries Down_Result { get; set; } [Output("Span A", LineStyle = LineStyle.Solid, LineColor = "Green")] public IndicatorDataSeries SA_Result { get; set; } [Output("Span B", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")] public IndicatorDataSeries SB_Result { get; set; } private IchimokuKinkoHyo _ICHI; protected override void Initialize() { _ICHI = Indicators.IchimokuKinkoHyo(Ten_Period, K_Period, SB_Period); } public override void Calculate(int index) { Ten_Result[index] = _ICHI.TenkanSen[index]; K_Result[index] = _ICHI.KijunSen[index]; C_Result[index - 26] = _ICHI.ChikouSpan[index]; SA_Result[index + 26] = (_ICHI.TenkanSen[index] + _ICHI.KijunSen[index]) / 2; SB_Result[index + 26] = _ICHI.SenkouSpanB[index]; Up_Result[index + 26] = (_ICHI.TenkanSen[index] + _ICHI.KijunSen[index]) / 2; Down_Result[index + 26] = _ICHI.SenkouSpanB[index]; } } }
it doesn't show chico span
@IRCtrader
amusleh
31 May 2022, 11:35
Hi,
Try this:
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
[Cloud("Up Kumo", "Down Kumo", Opacity = 0.2)]
public class AwIchimoku : Indicator
{
[Parameter("Tenkan sen", DefaultValue = 9, MinValue = 1)]
public int Ten_Period { get; set; }
[Parameter("Kijun sen", DefaultValue = 26, MinValue = 1)]
public int K_Period { get; set; }
[Parameter("Senkou span B", DefaultValue = 52, MinValue = 1)]
public int SB_Period { get; set; }
[Output("Tenkan sen", LineStyle = LineStyle.Solid, LineColor = "Red")]
public IndicatorDataSeries Ten_Result { get; set; }
[Output("Kijun sen", LineStyle = LineStyle.Solid, LineColor = "Blue")]
public IndicatorDataSeries K_Result { get; set; }
[Output("Chiku span", LineStyle = LineStyle.Solid, LineColor = "Purple")]
public IndicatorDataSeries C_Result { get; set; }
[Output("Up Kumo", LineStyle = LineStyle.Solid, LineColor = "Green")]
public IndicatorDataSeries Up_Result { get; set; }
[Output("Down Kumo", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")]
public IndicatorDataSeries Down_Result { get; set; }
[Output("Span A", LineStyle = LineStyle.Solid, LineColor = "Green")]
public IndicatorDataSeries SA_Result { get; set; }
[Output("Span B", LineStyle = LineStyle.Solid, LineColor = "FFFF6666")]
public IndicatorDataSeries SB_Result { get; set; }
private IchimokuKinkoHyo _ICHI;
protected override void Initialize()
{
_ICHI = Indicators.IchimokuKinkoHyo(Ten_Period, K_Period, SB_Period);
}
public override void Calculate(int index)
{
Ten_Result[index] = _ICHI.TenkanSen[index];
K_Result[index] = _ICHI.KijunSen[index];
SA_Result[index + 26] = (_ICHI.TenkanSen[index] + _ICHI.KijunSen[index]) / 2;
SB_Result[index + 26] = _ICHI.SenkouSpanB[index];
Up_Result[index + 26] = (_ICHI.TenkanSen[index] + _ICHI.KijunSen[index]) / 2;
Down_Result[index + 26] = _ICHI.SenkouSpanB[index];
C_Result[index - 26] = _ICHI.ChikouSpan[index - 26];
}
}
}
@amusleh
amusleh
30 May 2022, 09:39
Hi,
Try this:
@amusleh