{"id":1555,"date":"2024-05-02T13:00:00","date_gmt":"2024-05-02T13:00:00","guid":{"rendered":"https:\/\/www.tejwin.com\/en\/insights\/tquant-lab-ichimoku-kinko-hyo\/"},"modified":"2024-05-02T13:00:00","modified_gmt":"2024-05-02T13:00:00","slug":"tquant-lab-ichimoku-kinko-hyo","status":"publish","type":"insight","link":"https:\/\/www.tejwin.com\/en\/insights\/tquant-lab-ichimoku-kinko-hyo\/","title":{"rendered":"TQuant Lab Ichimoku Kinko Hyo Strategy, A Self-contained Technical Analysis Indicator"},"content":{"rendered":"<figure class=\"wp-block-image aligncenter size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-22909\" height=\"3720\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/Mt.-Fuji-photo.jpg\" style=\"aspect-ratio:1.5;object-fit:cover\" width=\"5719\"\/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/@manucosen?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash\" rel=\"noopener\" target=\"_blank\">Manuel Cosentino<\/a> on <a class=\"ek-link\" href=\"https:\/\/unsplash.com\/photos\/mt-fuji-n--CMLApjfI?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash\" rel=\"noopener\" target=\"_blank\">Unsplash<\/a><\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\"><strong><strong>Highlight<\/strong><\/strong><\/h2>\n<ul class=\"wp-block-list\">\n<li>Difficulty\uff1a\u2605\u2605\u2605\u2606\u2606<\/li>\n<li>Introduction to Ichimoku Kinko Hyo and trailing stop.<\/li>\n<li>Write an Ichimoku Kinko Hyo strategy using TQuant Lab backtesting platform and backtest risk and performance.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Ichimoku Kinko Hyo (also known as Cloud Charts, \u3044\u3061\u3082\u304f\u304d\u3093\u3053\u3046\u3072\u3087\u3046) was invented by Japanese journalist Goichi Hosoda, but it was not publicly disclosed at the time. Forty years later, between 1975 and 6 years after that, Goichi Hosoda, using the pseudonym Ichimoku Sanjin, published seven series of works under the name \u201cIchimoku Kinko Hyo,\u201d explaining in detail this indicator and the philosophical thinking behind its trading system.<\/p>\n<p class=\"wp-block-paragraph\">Unlike traditional concepts such as stock prices influenced by price-volume relationships, supply and demand for buying and selling, and fundamental aspects of companies, Ichimoku Kinko Hyo believes that time is an essential factor affecting price changes, especially under the influence of time, prices have cyclical changes. There is always a market concern that stocks will fall after rising for a long time and rise after falling for a long time. The overall market sentiment reflects a regularity of fluctuations in market behavior under the influence of time, which forms the basis of the \u201cTime Theory\u201d of Ichimoku Kinko Hyo.<\/p>\n<p class=\"wp-block-paragraph\">In addition, Ichimoku Kinko Hyo is a philosophical, technical analysis indicator. Rather than being an indicator per se, the author believes it should be regarded as Goichi Hosoda\u2019s analysis and reflection on the market and society. The thought behind it is worth exploring in depth. Due to space constraints, this article does not elaborate on this. The author believes that <a class=\"ek-link\" href=\"https:\/\/medium.com\/trading-mind\/%E4%B8%80%E7%9B%AE%E5%9D%87%E8%A1%A1%E8%A1%A8%E7%90%86%E8%AB%96%E8%88%87%E5%B8%82%E5%A0%B4%E5%B9%B3%E8%A1%A1-27b49068c95\" rel=\"noopener\" target=\"_blank\">the theory of Ichimoku Kinko Hyo and market equilibrium<\/a> has good insights into Ichimoku Kinko Hyo. Those interested can refer to it.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Introduction to Ichimoku Kinko Hyo Framework<\/strong><\/h2>\n<h3 class=\"wp-block-heading\"><strong>Time Theory<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">The time theory of Ichimoku Kinko Hyo is a method of analyzing time and market turning points. \u201c9, 17, 26\u201d are the basic numbers and can be used to examine whether the market will likely have a turning point during this period, which is a significant value.<\/p>\n<h3 class=\"wp-block-heading\"><strong>Interpretation Method<\/strong><\/h3>\n<ul class=\"wp-block-list\">\n<li>Conversion\u00a0Line (<code>tenkan_sen<\/code>): The turning line (also known as\u00a0the reversal line) is the average of the highest and lowest prices in the past nine days. If the turning line rises, it is judged that the upward momentum is strong, and if it falls, it is considered that the downward trend is strong.\u00a0Because it is calculated based on a\u00a0short\u00a0period\u00a0of nine days, it is used to analyze short-term trends.<\/li>\n<li>Base\u00a0Line (<code>kijun_sen<\/code>): The standard line\u00a0is the average of\u00a0the highest and lowest prices over the past 26 days. If the standard line rises, it is judged that the upward momentum is strong, and if it falls, it is considered that the downward trend is strong. Since it is calculated based on a period of 26 days, it is used to analyze medium-term trends.<\/li>\n<li>Leading Span A \/ B (<code>senkou_span_a\/b<\/code>): Leading Span A predicts the future trend for the next 26 days based on the average turning line and the standard line. Leading Span B is a line that predicts the trend for the next 26 days based on the average of the highest and lowest prices of the past 52 days. Since both show the average trend for the next 26 days, they help analyze future price changes. After shading between Leading Span A and Leading Span B, the \u201ccloud region or cloud band\u201d is called the part with A &lt; B, green, and the part with A &gt; B, red.<\/li>\n<li>Lagging Span (<code>chikou_span<\/code>): The lagging span is the stock price 26 days ago. If it is above the price line, it indicates a strong upward trend in the market; if it is below the price line, it indicates a solid downward trend.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\"><strong>Turning Lines and Standard Lines<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Ichimoku Kinko Hyo also has a method called \u201cThree-Line Confirmation\u201d and \u201cThree-Line Reversal\u201d for interpreting. \u201cThree-line confirmation\u201d represents a buy signal, and \u201cThree-Line Reversal\u201d represents a sell signal. Usually, if the three-line confirmation is met outside the stock\u2019s price range, there will be a stronger upward trend, and vice versa. This article will fine-tune the buy signal based on the three-line confirmation.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Conditions for Three-Line Confirmation:<\/strong><\/p>\n<ul class=\"wp-block-list\">\n<li>The Conversion Line exceeds the\u00a0Base Line.<\/li>\n<li>The Lagging Span is above the price.<\/li>\n<li>The price exceeds the cloud area.<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\"><strong>Conditions for Three-Line Reversal:<\/strong><\/p>\n<ul class=\"wp-block-list\">\n<li>The Conversion Line is below the\u00a0Base Line.<\/li>\n<li>The Lagging Span is below the price.<\/li>\n<li>The price is below the cloud area.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\"><strong>Editing Environment and Module Requirements<\/strong>\u00a0<\/h2>\n<p class=\"wp-block-paragraph\">This article uses MacOS and Jupyter Notebook as the editor.<\/p>\n<h2 class=\"wp-block-heading\"><strong>Data Import and Use of <code>get_universe<\/code> Function to Obtain Stock Pool<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">This strategy first fetches all stock codes of common stocks, including both listed and over-the-counter (OTC) markets, for one year, from April 1, 2018, to March 31, 2019.<\/p>\n<pre class=\"wp-block-code\"><code>import os\nimport tejapi\nimport pandas as pd\nimport numpy as np\n\nos.environ['TEJAPI_KEY'] = \"your key\"\nos.environ['TEJAPI_BASE'] = \"https:\/\/api.tej.com.tw\"\nstart = '2018-04-01'\nend = '2019-03-31'\nfrom zipline.sources.TEJ_Api_Data import get_universe\npool = get_universe(start, end, mkt = ['TWSE', 'OTC'], stktp_e=['Common Stock-Foreign', 'Common Stock'])\nlen(pool)<\/code><\/pre>\n<h3 class=\"wp-block-heading\"><strong>Using TEJToolAPI to Fetch MSCI Component Stocks<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">The Ichimoku Kinko Hyo strategy selects MSCI component stocks from the above stock codes using the TEJToolAPI.<\/p>\n<pre class=\"wp-block-code\"><code>average_vol = df.groupby('\u80a1\u7968\u4ee3\u78bc')['\u6210\u4ea4\u91cf_\u5343\u80a1'].mean().reset_index()\naverage_vol = average_vol.rename(columns={'\u6210\u4ea4\u91cf_\u5343\u80a1': '\u5e73\u5747\u6210\u4ea4\u91cf'})\nhigh_price_stocks = df.groupby('\u80a1\u7968\u4ee3\u78bc')['\u6700\u4f4e\u50f9'].min().reset_index()\nhigh_price_stocks = high_price_stocks[high_price_stocks['\u6700\u4f4e\u50f9'] &gt;= 50]\nmerge_data = pd.merge(average_vol, high_price_stocks, on='\u80a1\u7968\u4ee3\u78bc', how='inner')\ntop_100_vol = merge_data.sort_values(by='\u5e73\u5747\u6210\u4ea4\u91cf', ascending=False).head(100)\ntop_100_vol<\/code><\/pre>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-22914\" height=\"671\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-26-E4B88BE58D882.13.56.png\" width=\"807\"\/><\/figure>\n<h3 class=\"wp-block-heading\">Loading data into bundle<\/h3>\n<p class=\"wp-block-paragraph\">To avoid lookahead bias, this strategy\u2019s five-year backtesting period is from April 1, 2019, to April 1, 2024. It includes the aforementioned 91 constituent stocks, along with the Taiwan Weighted Index (<em>IR0001<\/em>), as a benchmark for market comparison.<\/p>\n<p class=\"wp-block-paragraph\">Below is the list of the 91 constituent stocks and the Taiwan Weighted Index:<\/p>\n<pre class=\"wp-block-code\"><code>!zipline ingest -b tquant\n!zipline bundle-info<\/code><\/pre>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23054\" height=\"278\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-30-E4B88BE58D884.26.58.png\" width=\"505\"\/><figcaption class=\"wp-element-caption\">Component stock and backtest period<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\"><strong>Creating Pipeline Function<\/strong><\/h2>\n<h3 class=\"wp-block-heading\"><strong>Creating Custom Factor<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">CustomFactor allows users to design custom factors as needed. In this case, we will use it to handle:<\/p>\n<p class=\"wp-block-paragraph\">Average True Range (ATR): Used to calculate trailing stop levels. Pipeline allows users to process quantitative indicators and price-volume data for multiple assets quickly. In this case, we will use it to handle:<\/p>\n<p class=\"wp-block-paragraph\">Conversion Line (tenkan_sen) Base Line (kijun_sen) Leading Span A \/ B (<code>senkou_span_a\/b<\/code>) Cloud area or cloud band (<code>cloud_red<\/code>) Lagging Span (<code>chikou_span<\/code>)<\/p>\n<pre class=\"wp-block-code\"><code>from zipline.pipeline import Pipeline\nfrom zipline.TQresearch.tej_pipeline import run_pipeline\ndef make_pipeline():\n    \n    Ich = IchimokuKinkoHyo(\n        inputs = [TWEquityPricing.high, TWEquityPricing.low, TWEquityPricing.close],\n        window_length = 52,\n    )\n    atr = AverageTrueRange(inputs = [TWEquityPricing.high, TWEquityPricing.low, TWEquityPricing.close],\n        window_length = 52,\n    )\n    \n    return Pipeline(\n        columns = {\n            'curr_price': TWEquityPricing.close.latest,\n            \"tenkan_sen\": Ich.tenkan_sen,\n            \"kijun_sen\": Ich.kijun_sen,\n            \"senkou_span_a\": Ich.senkou_span_a,\n            \"senkou_span_b\": Ich.senkou_span_b,\n            'cloud_red': Ich.senkou_span_a &lt; Ich.senkou_span_b,\n            \"chikou_span\": Ich.chikou_span,\n            'stop_loss': atr.ATR,\n    },\n        # screen = ~StaticAssets([benchmark_asset])\n        screen = ~StaticAssets([benchmark_asset]) &amp; (Ich.senkou_span_a &gt; 0) &amp; (Ich.senkou_span_b &gt; 0)\n    )\nmy_pipeline = run_pipeline(make_pipeline(), start_dt, end_dt)\nmy_pipeline<\/code><\/pre>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-22916\" height=\"562\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-26-E4B88BE58D882.21.14.png\" width=\"1595\"\/><figcaption class=\"wp-element-caption\">Pipeline partial data<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\"><strong>Creating Initialize Function<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">The<code> <strong>initialize()<\/strong><\/code> function defines the daily trading environment before trading begins. In this example, we set:<\/p>\n<ul class=\"wp-block-list\">\n<li>Slippage costs<\/li>\n<li>Transaction costs model for the Taiwan stock market<\/li>\n<li>Weighted return index (<em>IR0001<\/em>) as the benchmark<\/li>\n<li>Incorporating the Ichimoku Kinko Hyo indicators designed in Pipeline into the trading process<\/li>\n<li>Setting the <code>context.stop_loss<\/code> variable to record stop-loss points during backtesting<\/li>\n<li>Setting the <code>context.holding<\/code> variable to record whether a position in a particular stock is held<\/li>\n<li>Setting the <code>context.trailing_stop<\/code> variable to record whether\u00a0the trailing\u00a0stop is being applied<\/li>\n<li>Setting the <code>context.last_buy_price<\/code> variable to record the last purchase price<\/li>\n<li>Setting the <code>context.trailing_count<\/code> variable to record the number of trailing stop instances<\/li>\n<li>Setting the <code>context.buy_count<\/code> variable to limit the maximum number of trades per stock<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>from zipline.finance import slippage, commission\nfrom zipline.api import *\n\ndef initialize(context):\n    set_slippage(slippage.VolumeShareSlippage())\n    set_commission(commission.Custom_TW_Commission(min_trade_cost = 20, discount = 1.0, tax = 0.003))\n    attach_pipeline(make_pipeline(), 'mystrats')\n    set_benchmark(symbol('IR0001'))\n    context.stop_loss = {}\n    context.trailing_stop = {}\n    context.last_buy_price = {}\n    context.trailing_count = {}\n    context.holding = {}\n    context.buy_count = {}<\/code><\/pre>\n<h2 class=\"wp-block-heading\"><strong>Creating Handle_data Function<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">The <strong><code>handle_data()<\/code><\/strong> function is important for constructing the Ichimoku Kinko Hyo strategy. It is called every day after the start of backtesting, and its main tasks include setting trading strategies, placing orders, and recording trading information.<\/p>\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong>\u00a0To avoid the possibility of erroneous entry signals by the Ichimoku Kinko Hyo during periods of price consolidation, this article uses an additional *1.01 condition on <code>tenkan_sen<\/code> &gt; <code>kijun_sen<\/code>. This is done in the hope of entering the market only when the upward trend is sufficiently explicit, thereby achieving a certain degree of avoidance of consolidation periods.<\/p>\n<p class=\"wp-block-paragraph\">For detailed trading rules regarding this strategy, please refer to <a class=\"ek-link\" href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Quant\/blob\/11779ccbbad36e1856824faec200257b0c668c21\/%E4%B8%80%E7%9B%AE%E5%9D%87%E8%A1%A1%E8%A1%A8.ipynb\" rel=\"noopener\" target=\"_blank\">Ichimoku Kinko Hyo.ipynb<\/a><\/p>\n<pre class=\"wp-block-code\"><code>        # \u4e09\u5f79\u597d\u8f49 (tenkan_sen &gt; kijun_sen*1.015 : avoid the Darvas Box Theory)\n        if (curr_price &gt; senkou_span_b) and (cloud_red == True) and (tenkan_sen &gt; kijun_sen*1.01) and (context.buy_count[f'{i}'] &lt;= 5):\n            order_percent(i, 0.01)\n            buy = True\n            context.stop_loss[f'{i}'] = curr_price - (1.25 * stop_loss)\n            context.last_buy_price[f'{i}'] = curr_price\n            record(\n                **{\n                    f'buy_{sym}':buy\n                }\n            )\n            context.holding[f'{i}'] = True\n            context.buy_count[f'{i}'] += 1\n\n        # reset stop loss point\n        if (curr_price &gt;= (1.3**context.trailing_count[f'{i}'])*context.last_buy_price[f'{i}']) and (context.holding[f'{i}'] == True) and (context.trailing_stop[f'{i}'] == False):\n            context.stop_loss[f'{i}'] = 1.3*context.stop_loss[f'{i}']\n            context.trailing_stop[f'{i}'] = True\n            context.trailing_count[f'{i}'] += 1\n        elif (curr_price &gt;= (1.3**context.trailing_count[f'{i}'])*context.last_buy_price[f'{i}']) and (context.holding[f'{i}'] == True) and (context.trailing_stop[f'{i}'] == True):\n            context.stop_loss[f'{i}'] = 1.3*context.stop_loss[f'{i}']\n            context.trailing_count[f'{i}'] += 1\n        \n        if (curr_price &lt;= context.stop_loss[f'{i}']) and (context.holding[f'{i}'] == True):\n            order_target(i, 0)\n            sell = True\n            context.stop_loss[f'{i}'] = None\n            context.trailing_stop[f'{i}'] = None\n            context.trailing_count[f'{i}'] = None\n            record(\n                **{\n                    f'sell_{sym}':sell\n                }\n            )\n            context.holding[f'{i}'] = None\n            context.buy_count[f'{i}'] = None<\/code><\/pre>\n<h2 class=\"wp-block-heading\"><strong>Executing Trading Strategy<\/strong><\/h2>\n<p class=\"wp-block-paragraph\">Use the <code><strong>run_algorithm()<\/strong><\/code> function to execute the Ichimoku Kinko Hyo strategy as defined above. Set the trading period from start_dt (2019-04-01) to end_dt (2024-04-01), using the dataset tquant, with an initial capital of 20 million dollars. The output results represent the daily performance and trade details.<\/p>\n<pre class=\"wp-block-code\"><code>import matplotlib.pyplot as plt\nfrom zipline import run_algorithm\n\nresults = run_algorithm(\n    start = start_dt,\n    end = end_dt,\n    initialize = initialize,\n    bundle = 'tquant',\n    analyze = analyze,\n    capital_base = 2e7,\n    handle_data = handle_data\n)\n\nresults<\/code><\/pre>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23037\" height=\"830\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-30-E4B88BE58D882.01.36.png\" width=\"1378\"\/><figcaption class=\"wp-element-caption\">Changes in returns\u00a0and entry\/exit performance based on the Ichimoku Kinko Hyo strategy for individual stocks (red marks indicate buy signals, green marks indicate sell signals).<\/figcaption><\/figure>\n<figure class=\"wp-block-image size-full is-resized caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\u4e00\u76ee\u5747\u8861\u8868\u7b56\u7565\" class=\"wp-image-22920\" height=\"848\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-26-E4B88BE58D882.46.47.png\" style=\"width:840px;height:auto\" width=\"1215\"\/><figcaption class=\"wp-element-caption\">Backtest Details<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\">Evaluating performance using\u00a0Pyfolio<\/h2>\n<pre class=\"wp-block-code\"><code>import pyfolio as pf \nreturns, positions, transactions = pf.utils.extract_rets_pos_txn_from_zipline(results)\nbenchmark_rets = results['benchmark_return']\npf.tears.create_full_tear_sheet(returns=returns,\n                                positions=positions,\n                                transactions=transactions,\n                                benchmark_rets=benchmark_rets\n                                )<\/code><\/pre>\n<figure class=\"wp-block-image size-full is-resized caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23024\" height=\"1000\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E59088E4BDB5E59C96E5838F.png\" style=\"width:841px;height:auto\" width=\"1928\"\/><figcaption class=\"wp-element-caption\">Backtest Performance &amp; Benchmark Comparison Chart<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We can observe that the Ichimoku Kinko Hyo strategy has provided excellent performance over the 58 months, with an annualized return of 23.554% and a cumulative return of 178.194%. The profit performance is quite impressive. The Sharpe ratio 1.38 indicates a relatively high return compared to the risk. Additionally, the \u03b2 value of 0.66 suggests that the strategy\u2019s volatility is relatively insensitive to overall market volatility, reflecting the core concept of the Ichimoku Kinko Hyo system in detaching from the market.<\/p>\n<p class=\"wp-block-paragraph\">Regarding maximum drawdown, we can see a significant downturn during the systemic risk increase due to the epidemic between the 22nd and 23rd years. Stable growth trends have characterized other periods. Utilizing the entry signals provided by the Ichimoku Kinko Hyo, along with a strategy incorporating ATR trailing stops, is a robust approach for achieving consistent returns surpassing the market over the long term.<\/p>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23042\" height=\"500\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-30-E4B88BE58D882.40.14.png\" width=\"1602\"\/><figcaption class=\"wp-element-caption\">Monthly Returns Variation Chart<\/figcaption><\/figure>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23028\" height=\"608\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-30-E4B88BE58D881.19.05.png\" width=\"1632\"\/><figcaption class=\"wp-element-caption\">Portfolio Holdings Variation Chart (Top Ten)<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">It can be seen that the holding period for each stock is quite consistent, with little bias towards any particular stock.<\/p>\n<h3 class=\"wp-block-heading\">Viewing the performance of a specific stock under the Ichimoku Kinko Hyo strategy<\/h3>\n<pre class=\"wp-block-code\"><code>graph(2330, True)<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Since this strategy involves backtesting on a selection of stocks rather than individual stock backtesting, it\u2019s impossible to quickly ascertain\u00a0the\u00a0actual entry and exit points\u00a0for each stock\u00a0within the Ichimoku Kinko Hyo system.\u00a0Therefore, I have additionally written a function to facilitate the examination of individual stock trading situations. For more details, please refer to the\u00a0<strong><a class=\"ek-link\" href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Quant\/blob\/11779ccbbad36e1856824faec200257b0c668c21\/%E4%B8%80%E7%9B%AE%E5%9D%87%E8%A1%A1%E8%A1%A8.ipynb\" rel=\"noopener\" target=\"_blank\">source code<\/a><\/strong>\u00a0on GitHub.<\/p>\n<figure class=\"wp-block-image size-full caption-align-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"Ichimoku Kinko Hyo\" class=\"wp-image-23030\" height=\"487\" src=\"https:\/\/www.tejwin.com\/en\/wp-content\/uploads\/2026\/08\/E688AAE59C96-2024-04-30-E4B88BE58D881.19.59.png\" width=\"1744\"\/><figcaption class=\"wp-element-caption\">The individual Ichimoku Kinko Hyo entry and exit performance for each stock (Red marks indicate buy signals, while green marks indicate sell signals)<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">A notable point is that the entry method based on Ichimoku Kinko Hyo\u2019s three signals\u00a0does not\u00a0include exit criteria.\u00a0In practical testing, exiting based on the reversal of the three signals would result in losing many profitable trends. Therefore, this strategy employs a trailing stop-loss method for exits. For instance, in the chart above, you can see that the strategy had a sell order triggered by a stop-loss signal on TSMC (2330) at the beginning of 2021, capturing a trend lasting over half a year. However, apart from trailing stop-loss, one could incorporate profit-taking mechanisms such as setting profit targets or other means of securing gains. Additionally, strategies involving both long and short positions could be explored.<\/p>\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n<p class=\"wp-block-paragraph\">This strategy uses the Ichimoku Kinko Hyo for backtesting simulations, leveraging its signals of three conversions for entry and complementing it with trailing stop-loss for profit-taking, yielding promising backtest results. Investors are welcome to consider this approach.<\/p>\n<p class=\"wp-block-paragraph\">In the future, I will continue to introduce various indicators constructed using the TEJ database and backtest their performance. Therefore, readers interested in trading backtests are encouraged to explore <a class=\"ek-link\" href=\"https:\/\/tquant.tejwin.com\/\" rel=\"noopener\" target=\"_blank\"><strong>TQuant Lab<\/strong><\/a>\u2018s related solutions, utilizing high-quality databases to build their trading strategies.<\/p>\n<p class=\"wp-block-paragraph\"><strong>A friendly reminder:<\/strong>\u00a0This strategy is for reference only and does not constitute any recommendation for commodities or investments.<\/p>\n<div style=\"border: 1px black; border-style: solid none; text-align: center; border-color: #296580; padding: 24px; margin-top: 24px; margin-bottom: 24px;\">\n<p style=\"margin: 0px; font-size: 24px; font-weight: bold; line-height: 1.5;\">[TQuant Lab] Solving Your Quantitative Finance Pain Points<\/p>\n<p style=\"margin: 0px; font-size: 24px; font-weight: bold; line-height: 1.5;\">Comprehensively providing all the tools needed for trading backtesting.<\/p>\n<div style=\"margin-top: 32px;\"><a href=\"https:\/\/tquant.tejwin.com\/\" rel=\"noopener\" style=\"border: none; border-radius: 4px; background-color: #296580; color: white; font-size: 20px; width: fit-content; text-decoration: none; padding: 12px 30px 12px 30px;\" target=\"_blank\">Register and Start Your Trial<\/a><\/div>\n<\/div>\n<h2 class=\"wp-block-heading\">Source Code<\/h2>\n<p class=\"wp-block-paragraph\"><a class=\"ek-link\" href=\"https:\/\/github.com\/tejtw\/TEJAPI_Python_Medium_Quant\/blob\/11779ccbbad36e1856824faec200257b0c668c21\/%E4%B8%80%E7%9B%AE%E5%9D%87%E8%A1%A1%E8%A1%A8.ipynb\" rel=\"noopener\" target=\"_blank\">Click Here to Github<\/a><\/p>\n<h2 class=\"wp-block-heading\">Extended Reading<\/h2>\n<ul class=\"wp-block-list\">\n<li><a class=\"ek-link\" href=\"https:\/\/www.tejwin.com\/insight\/esg-etf\/\"><\/a><a href=\"https:\/\/www.tejwin.com\/wp-admin\/post.php?post=22962&amp;action=edit&amp;lang=en&amp;update_needed=1&amp;trid=328125&amp;language_code=en\">TQuant Lab Should ESG ETF Be a Buy? Backtest Performance of ESG ETF<\/a><\/li>\n<li><a class=\"ek-link\" href=\"https:\/\/www.tejwin.com\/insight\/tquant-lab-kd-%e6%8c%87%e6%a8%99%e7%ad%96%e7%95%a5\/\"><\/a><a href=\"https:\/\/www.tejwin.com\/wp-admin\/post.php?post=22519&amp;action=edit&amp;lang=en&amp;update_needed=1&amp;trid=328047&amp;language_code=en\">TQuant Lab KD Indicator Strategy: Exploring Stock Price Reversal Timing?<\/a><\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">About<\/h2>\n<ul class=\"wp-block-list\">\n<li><a class=\"ek-link\" href=\"https:\/\/github.com\/tejtw\/TQuant-Lab\" rel=\"noreferrer noopener\" target=\"_blank\">TQuant Lab Github<\/a><\/li>\n<li><a class=\"ek-link\" href=\"https:\/\/tquant.tejwin.com\/\" rel=\"noopener\" target=\"_blank\">TQuant Lab Home Page<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The Ichimoku Kinko Hyo strategy employed in this simulation utilizes the concept of the three-line conversion in the Ichimoku Cloud chart for backtesting, coupled with trailing stop-loss testing for profitability. Under the pen name Ichimoku Sanjin (\u3044\u3061\u3082\u304f\u3055\u3093\u3058\u3093 \/ Ichimoku Sanjin), Goichi Hosoda authored seven series of works detailing the philosophy behind this indicator and its trading system.<\/p>\n","protected":false},"featured_media":1545,"template":"","tags":[59,65,100],"insight_category":[16],"class_list":["post-1555","insight","type-insight","status-publish","has-post-thumbnail","hentry","tag-backtesting","tag-python","tag-quantitative-trading","insight_category-quant-data-science"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight\/1555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight"}],"about":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/types\/insight"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media\/1545"}],"wp:attachment":[{"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/media?parent=1555"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/tags?post=1555"},{"taxonomy":"insight_category","embeddable":true,"href":"https:\/\/www.tejwin.com\/en\/wp-json\/wp\/v2\/insight_category?post=1555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}