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.add_equity("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.is_ready:
            # 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", "senkou_a", self._ichimoku.senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b", self._ichimoku.senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "chikou", self._ichimoku.chikou.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_maximum", self._ichimoku.tenkan_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_minimum", self._ichimoku.tenkan_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_maximum", self._ichimoku.kijun_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_minimum", self._ichimoku.kijun_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_maximum", self._ichimoku.senkou_b_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_minimum", self._ichimoku.senkou_b_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_tenkan_senkou_a", self._ichimoku.delayed_tenkan_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_kijun_senkou_a", self._ichimoku.delayed_kijun_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_maximum_senkou_b", self._ichimoku.delayed_maximum_senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_minimum_senkou_b", self._ichimoku.delayed_minimum_senkou_b.current.value)

The following reference table describes the ICHIMOKU method:

ichimoku(symbol, tenkan_period, kijun_period, senkou_a_period, senkou_b_period, senkou_a_delay_period, senkou_b_delay_period, resolution=None, selector=None)[source]

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

Parameters:
  • symbol (Symbol) — The symbol whose ICHIMOKU we want
  • tenkan_period (int) — The period to calculate the Tenkan-sen period
  • kijun_period (int) — The period to calculate the Kijun-sen period
  • senkou_a_period (int) — The period to calculate the Tenkan-sen period
  • senkou_b_period (int) — The period to calculate the Tenkan-sen period
  • senkou_a_delay_period (int) — The period to calculate the Tenkan-sen period
  • senkou_b_delay_period (int) — The period to calculate the Tenkan-sen period
  • resolution (Resolution, optional) — The resolution
  • selector (Callable[IBaseData, TradeBar], optional) — Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar
Returns:

A new IchimokuKinkoHyo indicator with the specified periods and delays

Return type:

IchimokuKinkoHyo

ICHIMOKU(symbol, tenkanPeriod, kijunPeriod, senkouAPeriod, senkouBPeriod, senkouADelayPeriod, senkouBDelayPeriod, resolution=None, selector=None)[source]

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

Parameters:
  • symbol (Symbol) — The symbol whose ICHIMOKU we want
  • tenkanPeriod (Int32) — The period to calculate the Tenkan-sen period
  • kijunPeriod (Int32) — The period to calculate the Kijun-sen period
  • senkouAPeriod (Int32) — The period to calculate the Tenkan-sen period
  • senkouBPeriod (Int32) — The period to calculate the Tenkan-sen period
  • senkouADelayPeriod (Int32) — The period to calculate the Tenkan-sen period
  • senkouBDelayPeriod (Int32) — The period to calculate the Tenkan-sen period
  • resolution (Resolution, optional) — The resolution
  • selector (Func<IBaseData, TradeBar>, optional) — Selects a value from the BaseData to send into the indicator, if null defaults to casting the input value to a TradeBar
Returns:

A new IchimokuKinkoHyo indicator with the specified periods and delays

Return type:

IchimokuKinkoHyo

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.add_equity("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.is_ready:
            # 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", "senkou_a", self._ichimoku.senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b", self._ichimoku.senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "chikou", self._ichimoku.chikou.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_maximum", self._ichimoku.tenkan_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_minimum", self._ichimoku.tenkan_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_maximum", self._ichimoku.kijun_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_minimum", self._ichimoku.kijun_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_maximum", self._ichimoku.senkou_b_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_minimum", self._ichimoku.senkou_b_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_tenkan_senkou_a", self._ichimoku.delayed_tenkan_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_kijun_senkou_a", self._ichimoku.delayed_kijun_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_maximum_senkou_b", self._ichimoku.delayed_maximum_senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_minimum_senkou_b", self._ichimoku.delayed_minimum_senkou_b.current.value)

To register a manual indicator for automatic updates with the security data, call the RegisterIndicatorregister_indicator 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.add_equity("SPY", Resolution.DAILY).symbol
        self._ichimoku = IchimokuKinkoHyo(9, 26, 17, 52, 26, 26)
        self.register_indicator(self._symbol, self._ichimoku, Resolution.DAILY)

    def on_data(self, slice: Slice) -> None:
        if self._ichimoku.is_ready:
            # 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", "senkou_a", self._ichimoku.senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b", self._ichimoku.senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "chikou", self._ichimoku.chikou.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_maximum", self._ichimoku.tenkan_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "tenkan_minimum", self._ichimoku.tenkan_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_maximum", self._ichimoku.kijun_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "kijun_minimum", self._ichimoku.kijun_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_maximum", self._ichimoku.senkou_b_maximum.current.value)
            self.plot("IchimokuKinkoHyo", "senkou_b_minimum", self._ichimoku.senkou_b_minimum.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_tenkan_senkou_a", self._ichimoku.delayed_tenkan_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_kijun_senkou_a", self._ichimoku.delayed_kijun_senkou_a.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_maximum_senkou_b", self._ichimoku.delayed_maximum_senkou_b.current.value)
            self.plot("IchimokuKinkoHyo", "delayed_minimum_senkou_b", self._ichimoku.delayed_minimum_senkou_b.current.value)

The following reference table describes the IchimokuKinkoHyo constructor:

IchimokuKinkoHyo

class QuantConnect.Indicators.IchimokuKinkoHyo[source]

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)

get_enumerator()

Returns an enumerator that iterates through the history window.

Return type:

IEnumerator[IndicatorDataPoint]

reset()

Resets this indicator to its initial state

to_detailed_string()

Provides a more detailed string of this indicator in the form of {Name} - {Value}

Return type:

str

update(time, value)

Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise

Parameters:
  • time (datetime)
  • value (float)
Return type:

bool

update(input)

Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise

Parameters:
  • input (IBaseData)
Return type:

bool

property chikou

The Chikou Span component of the Ichimoku indicator

Returns:

The Chikou Span component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property consolidators

The data consolidators associated with this indicator if any

Returns:

The data consolidators associated with this indicator if any

Return type:

ISet[IDataConsolidator]

property current

Gets the current state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Returns:

Gets the current state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Return type:

IndicatorDataPoint

property delayed_kijun_senkou_a

The Delayed Kijun Senkou A component of the Ichimoku indicator

Returns:

The Delayed Kijun Senkou A component of the Ichimoku indicator

Return type:

WindowIndicator[IndicatorDataPoint]

property delayed_maximum_senkou_b

The Delayed Maximum Senkou B component of the Ichimoku indicator

Returns:

The Delayed Maximum Senkou B component of the Ichimoku indicator

Return type:

WindowIndicator[IndicatorDataPoint]

property delayed_minimum_senkou_b

The Delayed Minimum Senkou B component of the Ichimoku indicator

Returns:

The Delayed Minimum Senkou B component of the Ichimoku indicator

Return type:

WindowIndicator[IndicatorDataPoint]

property delayed_tenkan_senkou_a

The Delayed Tenkan Senkou A component of the Ichimoku indicator

Returns:

The Delayed Tenkan Senkou A component of the Ichimoku indicator

Return type:

WindowIndicator[IndicatorDataPoint]

property is_ready

Returns true if all of the sub-components of the Ichimoku indicator is ready

Returns:

Returns true if all of the sub-components of the Ichimoku indicator is ready

Return type:

bool

property item

Indexes the history windows, where index 0 is the most recent indicator value. If index is greater or equal than the current count, it returns null. If the index is greater or equal than the window size, it returns null and resizes the windows to i + 1.

Returns:

Indexes the history windows, where index 0 is the most recent indicator value. If index is greater or equal than the current count, it returns null. If the index is greater or equal than the window size, it returns null and resizes the windows to i + 1.

Return type:

IndicatorDataPoint

property kijun

The Kijun-sen component of the Ichimoku indicator

Returns:

The Kijun-sen component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property kijun_maximum

The Kijun-sen Maximum component of the Ichimoku indicator

Returns:

The Kijun-sen Maximum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property kijun_minimum

The Kijun-sen Minimum component of the Ichimoku indicator

Returns:

The Kijun-sen Minimum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property name

Gets a name for this indicator

Returns:

Gets a name for this indicator

Return type:

str

property previous

Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Returns:

Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Return type:

IndicatorDataPoint

property samples

Gets the number of samples processed by this indicator

Returns:

Gets the number of samples processed by this indicator

Return type:

int

property senkou_a

The Senkou A Span component of the Ichimoku indicator

Returns:

The Senkou A Span component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property senkou_b

The Senkou B Span component of the Ichimoku indicator

Returns:

The Senkou B Span component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property senkou_b_maximum

The Senkou B Maximum component of the Ichimoku indicator

Returns:

The Senkou B Maximum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property senkou_b_minimum

The Senkou B Minimum component of the Ichimoku indicator

Returns:

The Senkou B Minimum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property tenkan

The Tenkan-sen component of the Ichimoku indicator

Returns:

The Tenkan-sen component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property tenkan_maximum

The Tenkan-sen Maximum component of the Ichimoku indicator

Returns:

The Tenkan-sen Maximum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property tenkan_minimum

The Tenkan-sen Minimum component of the Ichimoku indicator

Returns:

The Tenkan-sen Minimum component of the Ichimoku indicator

Return type:

IndicatorBase[IndicatorDataPoint]

property warm_up_period

Required period, in data points, for the indicator to be ready and fully initialized.

Returns:

Required period, in data points, for the indicator to be ready and fully initialized.

Return type:

int

property window

A rolling window keeping a history of the indicator values of a given period

Returns:

A rolling window keeping a history of the indicator values of a given period

Return type:

RollingWindow[IndicatorDataPoint]

IchimokuKinkoHyo

class QuantConnect.Indicators.IchimokuKinkoHyo[source]

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)

GetEnumerator()

Returns an enumerator that iterates through the history window.

Return type:

IEnumerator[IndicatorDataPoint]

Reset()

Resets this indicator to its initial state

ToDetailedString()

Provides a more detailed string of this indicator in the form of {Name} - {Value}

Return type:

String

Update(time, value)

Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise

Parameters:
  • time (DateTime)
  • value (decimal)
Return type:

Boolean

Update(input)

Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise

Parameters:
  • input (IBaseData)
Return type:

Boolean

property Chikou

The Chikou Span component of the Ichimoku indicator

Returns:

The Chikou Span component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property Consolidators

The data consolidators associated with this indicator if any

Returns:

The data consolidators associated with this indicator if any

Return type:

ISet<IDataConsolidator>

property Current

Gets the current state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Returns:

Gets the current state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Return type:

IndicatorDataPoint

property DelayedKijunSenkouA

The Delayed Kijun Senkou A component of the Ichimoku indicator

Returns:

The Delayed Kijun Senkou A component of the Ichimoku indicator

Return type:

WindowIndicator<IndicatorDataPoint>

property DelayedMaximumSenkouB

The Delayed Maximum Senkou B component of the Ichimoku indicator

Returns:

The Delayed Maximum Senkou B component of the Ichimoku indicator

Return type:

WindowIndicator<IndicatorDataPoint>

property DelayedMinimumSenkouB

The Delayed Minimum Senkou B component of the Ichimoku indicator

Returns:

The Delayed Minimum Senkou B component of the Ichimoku indicator

Return type:

WindowIndicator<IndicatorDataPoint>

property DelayedTenkanSenkouA

The Delayed Tenkan Senkou A component of the Ichimoku indicator

Returns:

The Delayed Tenkan Senkou A component of the Ichimoku indicator

Return type:

WindowIndicator<IndicatorDataPoint>

property IsReady

Returns true if all of the sub-components of the Ichimoku indicator is ready

Returns:

Returns true if all of the sub-components of the Ichimoku indicator is ready

Return type:

bool

property Kijun

The Kijun-sen component of the Ichimoku indicator

Returns:

The Kijun-sen component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property KijunMaximum

The Kijun-sen Maximum component of the Ichimoku indicator

Returns:

The Kijun-sen Maximum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property KijunMinimum

The Kijun-sen Minimum component of the Ichimoku indicator

Returns:

The Kijun-sen Minimum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property Name

Gets a name for this indicator

Returns:

Gets a name for this indicator

Return type:

string

property Previous

Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Returns:

Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

Return type:

IndicatorDataPoint

property Samples

Gets the number of samples processed by this indicator

Returns:

Gets the number of samples processed by this indicator

Return type:

int

property SenkouA

The Senkou A Span component of the Ichimoku indicator

Returns:

The Senkou A Span component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property SenkouB

The Senkou B Span component of the Ichimoku indicator

Returns:

The Senkou B Span component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property SenkouBMaximum

The Senkou B Maximum component of the Ichimoku indicator

Returns:

The Senkou B Maximum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property SenkouBMinimum

The Senkou B Minimum component of the Ichimoku indicator

Returns:

The Senkou B Minimum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property Tenkan

The Tenkan-sen component of the Ichimoku indicator

Returns:

The Tenkan-sen component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property TenkanMaximum

The Tenkan-sen Maximum component of the Ichimoku indicator

Returns:

The Tenkan-sen Maximum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property TenkanMinimum

The Tenkan-sen Minimum component of the Ichimoku indicator

Returns:

The Tenkan-sen Minimum component of the Ichimoku indicator

Return type:

IndicatorBase<IndicatorDataPoint>

property WarmUpPeriod

Required period, in data points, for the indicator to be ready and fully initialized.

Returns:

Required period, in data points, for the indicator to be ready and fully initialized.

Return type:

Int32

property Window

A rolling window keeping a history of the indicator values of a given period

Returns:

A rolling window keeping a history of the indicator values of a given period

Return type:

RollingWindow<IndicatorDataPoint>

property [System.Int32]

Indexes the history windows, where index 0 is the most recent indicator value. If index is greater or equal than the current count, it returns null. If the index is greater or equal than the window size, it returns null and resizes the windows to i + 1.

Returns:

Indexes the history windows, where index 0 is the most recent indicator value. If index is greater or equal than the current count, it returns null. If the index is greater or equal than the window size, it returns null and resizes the windows to i + 1.

Return type:

IndicatorDataPoint

Visualization

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

IchimokuKinkoHyo line plot.

Indicator History

To get the historical data of the IchimokuKinkoHyo indicator, call the IndicatorHistoryself.indicator_history method. This method resets your indicator, makes a history request, and updates the indicator with the historical data. Just like with regular history requests, the IndicatorHistoryindicator_history method supports time periods based on a trailing number of bars, a trailing period of time, or a defined period of time. If you don't provide a resolution argument, it defaults to match the resolution of the security subscription.

public class IchimokuKinkoHyoAlgorithm : QCAlgorithm
{
    private Symbol _symbol;

    public override void Initialize()
    {
        _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        var ichimoku = ICHIMOKU(_symbol, 9, 26, 17, 52, 26, 26);
        var countIndicatorHistory = IndicatorHistory(ichimoku, _symbol, 100, Resolution.Minute);
        var timeSpanIndicatorHistory = IndicatorHistory(ichimoku, _symbol, TimeSpan.FromDays(10), Resolution.Minute);
        var timePeriodIndicatorHistory = IndicatorHistory(ichimoku, _symbol, new DateTime(2024, 7, 1), new DateTime(2024, 7, 5), Resolution.Minute);
    }
}
class IchimokuKinkoHyoAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self._symbol = self.add_equity("SPY", Resolution.DAILY).symbol
        ichimoku = self.ichimoku(self._symbol, 9, 26, 17, 52, 26, 26)
        count_indicator_history = self.indicator_history(ichimoku, self._symbol, 100, Resolution.MINUTE)
        timedelta_indicator_history = self.indicator_history(ichimoku, self._symbol, timedelta(days=10), Resolution.MINUTE)
        time_period_indicator_history = self.indicator_history(ichimoku, self._symbol, datetime(2024, 7, 1), datetime(2024, 7, 5), Resolution.MINUTE)

To make the IndicatorHistoryindicator_history method update the indicator with an alternative price field instead of the close (or mid-price) of each bar, pass a selector argument.

var indicatorHistory = IndicatorHistory(ichimoku, 100, Resolution.Minute, (bar) => ((TradeBar)bar).High);
indicator_history = self.indicator_history(ichimoku, 100, Resolution.MINUTE, lambda bar: bar.high)
indicator_history_df = indicator_history.data_frame

If you already have a list of Slice objects, you can pass them to the IndicatorHistoryindicator_history method to avoid the internal history request.

var history = History(_symbol, 100, Resolution.Minute);
var historyIndicatorHistory = IndicatorHistory(ichimoku, history);

To access the properties of the indicator history, invoke the property of each IndicatorDataPoint object.index the DataFrame with the property name.

var tenkan = indicatorHistory.Select(x => ((dynamic)x).Tenkan).ToList();
var kijun = indicatorHistory.Select(x => ((dynamic)x).Kijun).ToList();
var senkoua = indicatorHistory.Select(x => ((dynamic)x).SenkouA).ToList();
var senkoub = indicatorHistory.Select(x => ((dynamic)x).SenkouB).ToList();
var chikou = indicatorHistory.Select(x => ((dynamic)x).Chikou).ToList();
var tenkanmaximum = indicatorHistory.Select(x => ((dynamic)x).TenkanMaximum).ToList();
var tenkanminimum = indicatorHistory.Select(x => ((dynamic)x).TenkanMinimum).ToList();
var kijunmaximum = indicatorHistory.Select(x => ((dynamic)x).KijunMaximum).ToList();
var kijunminimum = indicatorHistory.Select(x => ((dynamic)x).KijunMinimum).ToList();
var senkoubmaximum = indicatorHistory.Select(x => ((dynamic)x).SenkouBMaximum).ToList();
var senkoubminimum = indicatorHistory.Select(x => ((dynamic)x).SenkouBMinimum).ToList();
var delayedtenkansenkoua = indicatorHistory.Select(x => ((dynamic)x).DelayedTenkanSenkouA).ToList();
var delayedkijunsenkoua = indicatorHistory.Select(x => ((dynamic)x).DelayedKijunSenkouA).ToList();
var delayedmaximumsenkoub = indicatorHistory.Select(x => ((dynamic)x).DelayedMaximumSenkouB).ToList();
var delayedminimumsenkoub = indicatorHistory.Select(x => ((dynamic)x).DelayedMinimumSenkouB).ToList();

// Alternative way
// var tenkan = indicatorHistory.Select(x => x["tenkan"]).ToList();
// var kijun = indicatorHistory.Select(x => x["kijun"]).ToList();
// var senkoua = indicatorHistory.Select(x => x["senkoua"]).ToList();
// var senkoub = indicatorHistory.Select(x => x["senkoub"]).ToList();
// var chikou = indicatorHistory.Select(x => x["chikou"]).ToList();
// var tenkanmaximum = indicatorHistory.Select(x => x["tenkanmaximum"]).ToList();
// var tenkanminimum = indicatorHistory.Select(x => x["tenkanminimum"]).ToList();
// var kijunmaximum = indicatorHistory.Select(x => x["kijunmaximum"]).ToList();
// var kijunminimum = indicatorHistory.Select(x => x["kijunminimum"]).ToList();
// var senkoubmaximum = indicatorHistory.Select(x => x["senkoubmaximum"]).ToList();
// var senkoubminimum = indicatorHistory.Select(x => x["senkoubminimum"]).ToList();
// var delayedtenkansenkoua = indicatorHistory.Select(x => x["delayedtenkansenkoua"]).ToList();
// var delayedkijunsenkoua = indicatorHistory.Select(x => x["delayedkijunsenkoua"]).ToList();
// var delayedmaximumsenkoub = indicatorHistory.Select(x => x["delayedmaximumsenkoub"]).ToList();
// var delayedminimumsenkoub = indicatorHistory.Select(x => x["delayedminimumsenkoub"]).ToList();
tenkan = indicator_history_df["tenkan"]
kijun = indicator_history_df["kijun"]
senkou_a = indicator_history_df["senkou_a"]
senkou_b = indicator_history_df["senkou_b"]
chikou = indicator_history_df["chikou"]
tenkan_maximum = indicator_history_df["tenkan_maximum"]
tenkan_minimum = indicator_history_df["tenkan_minimum"]
kijun_maximum = indicator_history_df["kijun_maximum"]
kijun_minimum = indicator_history_df["kijun_minimum"]
senkou_b_maximum = indicator_history_df["senkou_b_maximum"]
senkou_b_minimum = indicator_history_df["senkou_b_minimum"]
delayed_tenkan_senkou_a = indicator_history_df["delayed_tenkan_senkou_a"]
delayed_kijun_senkou_a = indicator_history_df["delayed_kijun_senkou_a"]
delayed_maximum_senkou_b = indicator_history_df["delayed_maximum_senkou_b"]
delayed_minimum_senkou_b = indicator_history_df["delayed_minimum_senkou_b"]

# Alternative way
# tenkan = indicator_history_df.tenkan
# kijun = indicator_history_df.kijun
# senkou_a = indicator_history_df.senkou_a
# senkou_b = indicator_history_df.senkou_b
# chikou = indicator_history_df.chikou
# tenkan_maximum = indicator_history_df.tenkan_maximum
# tenkan_minimum = indicator_history_df.tenkan_minimum
# kijun_maximum = indicator_history_df.kijun_maximum
# kijun_minimum = indicator_history_df.kijun_minimum
# senkou_b_maximum = indicator_history_df.senkou_b_maximum
# senkou_b_minimum = indicator_history_df.senkou_b_minimum
# delayed_tenkan_senkou_a = indicator_history_df.delayed_tenkan_senkou_a
# delayed_kijun_senkou_a = indicator_history_df.delayed_kijun_senkou_a
# delayed_maximum_senkou_b = indicator_history_df.delayed_maximum_senkou_b
# delayed_minimum_senkou_b = indicator_history_df.delayed_minimum_senkou_b

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: