Skip to content

IchimokuKinkoHyo

Summary

Ichimoku Kinko Hyo Indicator.

Remarks

Ichimoku is a moving average based trend identification system. It contains more data points than standard candlestick charts and thus provides a clearer picture of potential price action.

Signature

1
public abstract interface IchimokuKinkoHyo

Namespace

cAlgo.API.Indicators

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 //...
 private IchimokuKinkoHyo ichimokuKinkoHyo;
 //...
 protected override void OnStart()
 {
     ichimokuKinkoHyo = Indicators.IchimokuKinkoHyo
         (tenkanSenPeriods, kijunSenPeriods, senkouSpanBPeriods);
 }
 protected override void OnBar()
 {
     Print("ChikouSpan Value = {0}", ichimokuKinkoHyo.ChikouSpan.LastValue);
     Print("KijunSen Value = {0}", ichimokuKinkoHyo.KijunSen.LastValue);
     Print("SenkouSpanA Value = {0}", ichimokuKinkoHyo.SenkouSpanA.LastValue);
     Print("SenkouSpanB Value = {0}", ichimokuKinkoHyo.SenkouSpanB.LastValue);
     Print("TenkanSen Value = {0}", ichimokuKinkoHyo.TenkanSen.LastValue);
     //...
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 using cAlgo.API;
 using cAlgo.API.Indicators;
 namespace cAlgo.Robots
 {
     /// 
     /// This sample cBot shows how to use the Ichimoku Kinko Hyo indicator
     /// 
     [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class IchimokuKinkoHyoSample : Robot
     {
         private double _volumeInUnits;
         private IchimokuKinkoHyo _ichimokuKinkoHyo;
         [Parameter("Volume (Lots)", DefaultValue = 0.01)]
         public double VolumeInLots { get; set; }
         [Parameter("Stop Loss (Pips)", DefaultValue = 10)]
         public double StopLossInPips { get; set; }
         [Parameter("Take Profit (Pips)", DefaultValue = 10)]
         public double TakeProfitInPips { get; set; }
         [Parameter("Label", DefaultValue = "Sample")]
         public string Label { get; set; }
         public Position[] BotPositions
         {
             get
             {
                 return Positions.FindAll(Label);
             }
         }
         protected override void OnStart()
         {
             _volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
             _ichimokuKinkoHyo = Indicators.IchimokuKinkoHyo(9, 26, 52);
         }
         protected override void OnBar()
         {
             if (Bars.ClosePrices.Last(1) > _ichimokuKinkoHyo.SenkouSpanB.Last(1))
             {
                 ClosePositions(TradeType.Sell);
                 if (_ichimokuKinkoHyo.TenkanSen.Last(1) > _ichimokuKinkoHyo.KijunSen.Last(1) && _ichimokuKinkoHyo.TenkanSen.Last(2) <= _ichimokuKinkoHyo.KijunSen.Last(2))
                 {
                     ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
                 }
             }
             else if (Bars.ClosePrices.Last(1) < _ichimokuKinkoHyo.SenkouSpanA.Last(1))
             {
                 ClosePositions(TradeType.Buy);
                 if (_ichimokuKinkoHyo.TenkanSen.Last(1) < _ichimokuKinkoHyo.KijunSen.Last(1) && _ichimokuKinkoHyo.TenkanSen.Last(2) >= _ichimokuKinkoHyo.KijunSen.Last(2))
                 {
                     ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label, StopLossInPips, TakeProfitInPips);
                 }
             }
         }
         private void ClosePositions(TradeType tradeType)
         {
             foreach (var position in BotPositions)
             {
                 if (position.TradeType != tradeType) continue;
                 ClosePosition(position);
             }
         }
     }
 }

Properties

KijunSen

Summary

This is a confirmation line, a support-resistance line, and can be used as a trailing stop line.

Signature

1
public abstract IndicatorDataSeries KijunSen {get; set;}

Return Value

IndicatorDataSeries

Examples

1
 Print("KijunSen Value = {0}", ichimokuKinkoHyo.KijunSen.LastValue);

TenkanSen

Summary

It is primarily used as a signal line and a minor support-resistance line.

Signature

1
public abstract IndicatorDataSeries TenkanSen {get; set;}

Return Value

IndicatorDataSeries

Examples

1
 Print("TenkanSen Value = {0}", ichimokuKinkoHyo.TenkanSen.LastValue);

ChikouSpan

Summary

It is used as a support-resistance aid.

Signature

1
public abstract IndicatorDataSeries ChikouSpan {get; set;}

Return Value

IndicatorDataSeries

Examples

1
 Print("ChikouSpan Value = {0}", ichimokuKinkoHyo.ChikouSpan.LastValue);

SenkouSpanA

Summary

Leading span 1, this line forms one edge of the kumo, or cloud.If the price is above the Senkou span, the top line serves as the first support level while the bottom line serves as the second support level.

Signature

1
public abstract IndicatorDataSeries SenkouSpanA {get; set;}

Return Value

IndicatorDataSeries

Examples

1
 Print("SenkouSpanA Value = {0}", ichimokuKinkoHyo.SenkouSpanA.LastValue);

SenkouSpanB

Summary

Leading span 2, this line forms the other edge of the kumo.

Signature

1
public abstract IndicatorDataSeries SenkouSpanB {get; set;}

Return Value

IndicatorDataSeries

Examples

1
 Print("SenkouSpanB Value = {0}", ichimokuKinkoHyo.SenkouSpanB.LastValue);