Supported Indicators

Ichimoku Kinko Hyo

Introduction

This indicator computes the Ichimoku Kinko Hyo indicator. It consists of the following main indicators: Tenkan-sen: (Highest High + Lowest Low) / 2 for the specific period (normally 9) Kijun-sen: (Highest High + Lowest Low) / 2 for the specific period (normally 26) Senkou A Span: (Tenkan-sen + Kijun-sen )/ 2 from a specific number of periods ago (normally 26) Senkou B Span: (Highest High + Lowest Low) / 2 for the specific period (normally 52), from a specific number of periods ago (normally 26)

To view the implementation of this indicator, see the LEAN GitHub repository.

Using ICHIMOKU Indicator

To create an automatic indicators for IchimokuKinkoHyo, call the ICHIMOKU helper method from the QCAlgorithm class. The ICHIMOKU method creates a IchimokuKinkoHyo object, hooks it up for automatic updates, and returns it so you can used it in your algorithm. In most cases, you should call the helper method in the Initializeinitialize method.

public class IchimokuKinkoHyoAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private IchimokuKinkoHyo _ichimoku;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _ichimoku = ICHIMOKU(_symbol, 9, 26, 17, 52, 26, 26);
    }

    public override void OnData(Slice data)
    {
        if (_ichimoku.IsReady)
        {
            // The current value of _ichimoku is represented by itself (_ichimoku)
            // or _ichimoku.Current.Value
            Plot("IchimokuKinkoHyo", "ichimoku", _ichimoku);
            // Plot all properties of ichimoku
            Plot("IchimokuKinkoHyo", "tenkan", _ichimoku.Tenkan);
            Plot("IchimokuKinkoHyo", "kijun", _ichimoku.Kijun);
            Plot("IchimokuKinkoHyo", "senkoua", _ichimoku.SenkouA);
            Plot("IchimokuKinkoHyo", "senkoub", _ichimoku.SenkouB);
            Plot("IchimokuKinkoHyo", "chikou", _ichimoku.Chikou);
            Plot("IchimokuKinkoHyo", "tenkanmaximum", _ichimoku.TenkanMaximum);
            Plot("IchimokuKinkoHyo", "tenkanminimum", _ichimoku.TenkanMinimum);
            Plot("IchimokuKinkoHyo", "kijunmaximum", _ichimoku.KijunMaximum);
            Plot("IchimokuKinkoHyo", "kijunminimum", _ichimoku.KijunMinimum);
            Plot("IchimokuKinkoHyo", "senkoubmaximum", _ichimoku.SenkouBMaximum);
            Plot("IchimokuKinkoHyo", "senkoubminimum", _ichimoku.SenkouBMinimum);
            Plot("IchimokuKinkoHyo", "delayedtenkansenkoua", _ichimoku.DelayedTenkanSenkouA);
            Plot("IchimokuKinkoHyo", "delayedkijunsenkoua", _ichimoku.DelayedKijunSenkouA);
            Plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", _ichimoku.DelayedMaximumSenkouB);
            Plot("IchimokuKinkoHyo", "delayedminimumsenkoub", _ichimoku.DelayedMinimumSenkouB);
        }
    }
}
class IchimokuKinkoHyoAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self._symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.ichimoku = self.ICHIMOKU(self.symbol, 9, 26, 17, 52, 26, 26)

    def on_data(self, slice: Slice) -> None:
        if self.ichimoku.IsReady:
            # The current value of self.ichimoku is represented by self.ichimoku.Current.Value
            self.plot("IchimokuKinkoHyo", "ichimoku", self.ichimoku.Current.Value)
            # Plot all attributes of self.ichimoku
            self.plot("IchimokuKinkoHyo", "tenkan", self.ichimoku.Tenkan.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijun", self.ichimoku.Kijun.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoua", self.ichimoku.SenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoub", self.ichimoku.SenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "chikou", self.ichimoku.Chikou.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanmaximum", self.ichimoku.TenkanMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanminimum", self.ichimoku.TenkanMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunmaximum", self.ichimoku.KijunMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunminimum", self.ichimoku.KijunMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubmaximum", self.ichimoku.SenkouBMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubminimum", self.ichimoku.SenkouBMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedtenkansenkoua", self.ichimoku.DelayedTenkanSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedkijunsenkoua", self.ichimoku.DelayedKijunSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", self.ichimoku.DelayedMaximumSenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedminimumsenkoub", self.ichimoku.DelayedMinimumSenkouB.Current.Value)

The following reference table describes the ICHIMOKU method:

ICHIMOKU()1/1

            IchimokuKinkoHyo QuantConnect.Algorithm.QCAlgorithm.ICHIMOKU (
    Symbol                            symbol,
    Int32                             tenkanPeriod,
    Int32                             kijunPeriod,
    Int32                             senkouAPeriod,
    Int32                             senkouBPeriod,
    Int32                             senkouADelayPeriod,
    Int32                             senkouBDelayPeriod,
    *Nullable<Resolution>       resolution,
    *Func<IBaseData, TradeBar>  selector
   )
        

Creates a new IchimokuKinkoHyo indicator for the symbol. The indicator will be automatically updated on the given resolution.

If you don't provide a resolution, it defaults to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.

For more information about the selector argument, see Alternative Price Fields.

For more information about plotting indicators, see Plotting Indicators.

You can manually create a IchimokuKinkoHyo indicator, so it doesn't automatically update. Manual indicators let you update their values with any data you choose.

Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Updateupdate method with a TradeBar or QuoteBar. The indicator will only be ready after you prime it with enough data.

public class IchimokuKinkoHyoAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private IchimokuKinkoHyo _ichimoku;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _ichimoku = new IchimokuKinkoHyo(9, 26, 17, 52, 26, 26);
    }

    public override void OnData(Slice data)
    {
        if (data.Bars.TryGetValue(_symbol, out var bar))
        {      
            _ichimoku.Update(bar);
        }
   
        if (_ichimoku.IsReady)
        {
            // The current value of _ichimoku is represented by itself (_ichimoku)
            // or _ichimoku.Current.Value
            Plot("IchimokuKinkoHyo", "ichimoku", _ichimoku);
            // Plot all properties of ichimoku
            Plot("IchimokuKinkoHyo", "tenkan", _ichimoku.Tenkan);
            Plot("IchimokuKinkoHyo", "kijun", _ichimoku.Kijun);
            Plot("IchimokuKinkoHyo", "senkoua", _ichimoku.SenkouA);
            Plot("IchimokuKinkoHyo", "senkoub", _ichimoku.SenkouB);
            Plot("IchimokuKinkoHyo", "chikou", _ichimoku.Chikou);
            Plot("IchimokuKinkoHyo", "tenkanmaximum", _ichimoku.TenkanMaximum);
            Plot("IchimokuKinkoHyo", "tenkanminimum", _ichimoku.TenkanMinimum);
            Plot("IchimokuKinkoHyo", "kijunmaximum", _ichimoku.KijunMaximum);
            Plot("IchimokuKinkoHyo", "kijunminimum", _ichimoku.KijunMinimum);
            Plot("IchimokuKinkoHyo", "senkoubmaximum", _ichimoku.SenkouBMaximum);
            Plot("IchimokuKinkoHyo", "senkoubminimum", _ichimoku.SenkouBMinimum);
            Plot("IchimokuKinkoHyo", "delayedtenkansenkoua", _ichimoku.DelayedTenkanSenkouA);
            Plot("IchimokuKinkoHyo", "delayedkijunsenkoua", _ichimoku.DelayedKijunSenkouA);
            Plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", _ichimoku.DelayedMaximumSenkouB);
            Plot("IchimokuKinkoHyo", "delayedminimumsenkoub", _ichimoku.DelayedMinimumSenkouB);
        }
    }
}
class IchimokuKinkoHyoAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self._symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.ichimoku = IchimokuKinkoHyo(9, 26, 17, 52, 26, 26)

    def on_data(self, slice: Slice) -> None:
        bar = slice.Bars.get(self.symbol)
        if bar:
            self.ichimoku.Update(bar)
        if self.ichimoku.IsReady:
            # The current value of self.ichimoku is represented by self.ichimoku.Current.Value
            self.plot("IchimokuKinkoHyo", "ichimoku", self.ichimoku.Current.Value)
            # Plot all attributes of self.ichimoku
            self.plot("IchimokuKinkoHyo", "tenkan", self.ichimoku.Tenkan.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijun", self.ichimoku.Kijun.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoua", self.ichimoku.SenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoub", self.ichimoku.SenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "chikou", self.ichimoku.Chikou.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanmaximum", self.ichimoku.TenkanMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanminimum", self.ichimoku.TenkanMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunmaximum", self.ichimoku.KijunMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunminimum", self.ichimoku.KijunMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubmaximum", self.ichimoku.SenkouBMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubminimum", self.ichimoku.SenkouBMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedtenkansenkoua", self.ichimoku.DelayedTenkanSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedkijunsenkoua", self.ichimoku.DelayedKijunSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", self.ichimoku.DelayedMaximumSenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedminimumsenkoub", self.ichimoku.DelayedMinimumSenkouB.Current.Value)

To register a manual indicator for automatic updates with the security data, call the RegisterIndicator method.

public class IchimokuKinkoHyoAlgorithm : QCAlgorithm
{
    private Symbol _symbol;
    private IchimokuKinkoHyo _ichimoku;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        _ichimoku = new IchimokuKinkoHyo(9, 26, 17, 52, 26, 26);
        RegisterIndicator(_symbol, _ichimoku, Resolution.Daily);
    }

    public override void OnData(Slice data)
    {
        if (_ichimoku.IsReady)
        {
            // The current value of _ichimoku is represented by itself (_ichimoku)
            // or _ichimoku.Current.Value
            Plot("IchimokuKinkoHyo", "ichimoku", _ichimoku);
            // Plot all properties of ichimoku
            Plot("IchimokuKinkoHyo", "tenkan", _ichimoku.Tenkan);
            Plot("IchimokuKinkoHyo", "kijun", _ichimoku.Kijun);
            Plot("IchimokuKinkoHyo", "senkoua", _ichimoku.SenkouA);
            Plot("IchimokuKinkoHyo", "senkoub", _ichimoku.SenkouB);
            Plot("IchimokuKinkoHyo", "chikou", _ichimoku.Chikou);
            Plot("IchimokuKinkoHyo", "tenkanmaximum", _ichimoku.TenkanMaximum);
            Plot("IchimokuKinkoHyo", "tenkanminimum", _ichimoku.TenkanMinimum);
            Plot("IchimokuKinkoHyo", "kijunmaximum", _ichimoku.KijunMaximum);
            Plot("IchimokuKinkoHyo", "kijunminimum", _ichimoku.KijunMinimum);
            Plot("IchimokuKinkoHyo", "senkoubmaximum", _ichimoku.SenkouBMaximum);
            Plot("IchimokuKinkoHyo", "senkoubminimum", _ichimoku.SenkouBMinimum);
            Plot("IchimokuKinkoHyo", "delayedtenkansenkoua", _ichimoku.DelayedTenkanSenkouA);
            Plot("IchimokuKinkoHyo", "delayedkijunsenkoua", _ichimoku.DelayedKijunSenkouA);
            Plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", _ichimoku.DelayedMaximumSenkouB);
            Plot("IchimokuKinkoHyo", "delayedminimumsenkoub", _ichimoku.DelayedMinimumSenkouB);
        }
    }
}
class IchimokuKinkoHyoAlgorithm(QCAlgorithm):
    def Initialize(self) -> None:
        self._symbol = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.ichimoku = IchimokuKinkoHyo(9, 26, 17, 52, 26, 26)
        self.RegisterIndicator(self.symbol, self.ichimoku, Resolution.Daily)

    def on_data(self, slice: Slice) -> None:
        if self.ichimoku.IsReady:
            # The current value of self.ichimoku is represented by self.ichimoku.Current.Value
            self.plot("IchimokuKinkoHyo", "ichimoku", self.ichimoku.Current.Value)
            # Plot all attributes of self.ichimoku
            self.plot("IchimokuKinkoHyo", "tenkan", self.ichimoku.Tenkan.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijun", self.ichimoku.Kijun.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoua", self.ichimoku.SenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoub", self.ichimoku.SenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "chikou", self.ichimoku.Chikou.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanmaximum", self.ichimoku.TenkanMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "tenkanminimum", self.ichimoku.TenkanMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunmaximum", self.ichimoku.KijunMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "kijunminimum", self.ichimoku.KijunMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubmaximum", self.ichimoku.SenkouBMaximum.Current.Value)
            self.plot("IchimokuKinkoHyo", "senkoubminimum", self.ichimoku.SenkouBMinimum.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedtenkansenkoua", self.ichimoku.DelayedTenkanSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedkijunsenkoua", self.ichimoku.DelayedKijunSenkouA.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedmaximumsenkoub", self.ichimoku.DelayedMaximumSenkouB.Current.Value)
            self.plot("IchimokuKinkoHyo", "delayedminimumsenkoub", self.ichimoku.DelayedMinimumSenkouB.Current.Value)

The following reference table describes the IchimokuKinkoHyo constructor:

IchimokuKinkoHyo()1/2

            IchimokuKinkoHyo QuantConnect.Indicators.IchimokuKinkoHyo (
    *int  tenkanPeriod,
    *int  kijunPeriod,
    *int  senkouAPeriod,
    *int  senkouBPeriod,
    *int  senkouADelayPeriod,
    *int  senkouBDelayPeriod
   )
        

Creates a new IchimokuKinkoHyo indicator from the specific periods.

IchimokuKinkoHyo()2/2

            IchimokuKinkoHyo QuantConnect.Indicators.IchimokuKinkoHyo (
    string  name,
    *int    tenkanPeriod,
    *int    kijunPeriod,
    *int    senkouAPeriod,
    *int    senkouBPeriod,
    *int    senkouADelayPeriod,
    *int    senkouBDelayPeriod
   )
        

Creates a new IchimokuKinkoHyo indicator from the specific periods.

Visualization

The following image shows plot values of selected properties of IchimokuKinkoHyo using the plotly library.

IchimokuKinkoHyo line plot.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: