Skip to content

IchimokuKinkoHyo

interface cAlgo.API.Indicators

DesktopCLICloud

Ichimoku Kinko Hyo Indicator.

Definition

public interface IchimokuKinkoHyo

Namespace: cAlgo.API.Indicators · Group: Indicators · Implements: StandardIndicator

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.

Examples

Example 1

//...
private IchimokuKinkoHyo ichimokuKinkoHyo;
//...
protected override void OnStart()
{
    ichimokuKinkoHyo = Indicators.IchimokuKinkoHyo(9, 26, 52);
}
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);

    //...
}
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *
import math

class Test():
    def on_start(self):
        self.ichimokuKinkoHyo = api.Indicators.IchimokuKinkoHyo(9, 26, 52)

    def on_bar(self):
        api.Print(f"ChikouSpan Value = {self.ichimokuKinkoHyo.ChikouSpan.LastValue}")
        api.Print(f"KijunSen Value = {self.ichimokuKinkoHyo.KijunSen.LastValue}")
        api.Print(f"SenkouSpanA Value = {self.ichimokuKinkoHyo.SenkouSpanA.LastValue}")
        api.Print(f"SenkouSpanB Value = {self.ichimokuKinkoHyo.SenkouSpanB.LastValue}")
        api.Print(f"TenkanSen Value = {self.ichimokuKinkoHyo.TenkanSen.LastValue}")

Example 2

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Robots
{
    // This sample cBot shows how to use the Ichimoku Kinko Hyo indicator
    public partial class IchimokuKinkoHyoSample : Robot
    {
        private double _volumeInUnits;

        private IchimokuKinkoHyo _ichimokuKinkoHyo;

        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);
            }
        }
    }
}
import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class IchimokuKinkoHyoSample():
    def on_start(self):
        self.volumeInUnits = api.Symbol.QuantityToVolumeInUnits(api.VolumeInLots)
        self.ichimokuKinkoHyo = api.Indicators.IchimokuKinkoHyo(9, 26, 52)

    def on_bar_closed(self):
        if api.Bars.ClosePrices.Last(0) > self.ichimokuKinkoHyo.SenkouSpanB.Last(0):
            self.close_positions(TradeType.Sell)
            if self.ichimokuKinkoHyo.TenkanSen.Last(0) > self.ichimokuKinkoHyo.KijunSen.Last(0) and self.ichimokuKinkoHyo.TenkanSen.Last(1) <= self.ichimokuKinkoHyo.KijunSen.Last(1):
                api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)
        elif api.Bars.ClosePrices.Last(0) < self.ichimokuKinkoHyo.SenkouSpanA.Last(0):
            self.close_positions(TradeType.Buy)
            if self.ichimokuKinkoHyo.TenkanSen.Last(0) < self.ichimokuKinkoHyo.KijunSen.Last(0) and self.ichimokuKinkoHyo.TenkanSen.Last(1) >= self.ichimokuKinkoHyo.KijunSen.Last(1):
                api.ExecuteMarketOrder(TradeType.Sell, api.SymbolName, self.volumeInUnits, api.Label, api.StopLossInPips, api.TakeProfitInPips)

    def get_bot_positions(self):
        return api.Positions.FindAll(api.Label)

    def close_positions(self, tradeType):
        for position in self.get_bot_positions():
            if position.TradeType != tradeType:
                continue
            api.ClosePosition(position)
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "Parameters": [
    {
      "Name": "VolumeInLots",
      "DisplayName": "Volume (Lots)",
      "Type": "Double",
      "DefaultValue": 0.01
    },
    {
      "Name": "StopLossInPips",
      "DisplayName": "Stop Loss (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "TakeProfitInPips",
      "DisplayName": "Take Profit (Pips)",
      "Type": "Double",
      "DefaultValue": 10
    },
    {
      "Name": "Label",
      "Type": "String",
      "DefaultValue": "Sample"
    }
  ]
}

Properties

Name Description
ChikouSpanDesktopCLICloudIndicatorDataSeries It is used as a support-resistance aid.
KijunSenDesktopCLICloudIndicatorDataSeries This is a confirmation line, a support-resistance line, and can be used as a trailing stop line.
SenkouSpanADesktopCLICloudIndicatorDataSeries 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.
SenkouSpanBDesktopCLICloudIndicatorDataSeries Leading span 2, this line forms the other edge of the kumo.
TenkanSenDesktopCLICloudIndicatorDataSeries It is primarily used as a signal line and a minor support-resistance line.

Inherited members

From StandardIndicator: AddToChart, Symbol, TimeFrame, Bars