Ichimoku Cloud Trading Strategy
This strategy implements simple trend-following trading based on the ichimoku cloud indicator on daily charts. It generates buy and sell signals by calculating the conversion line, base line, leading span 1, leading…
Overview
This strategy implements simple trend-following trading based on the ichimoku cloud indicator on daily charts. It generates buy and sell signals by calculating the conversion line, base line, leading span 1, leading span 2, and comparing the closing price's position relative to the cloud. When the closing price is above the cloud, it is considered an upward trend and a buy signal is generated. When the closing price is below the cloud, it is considered a downward trend and a sell signal is generated.
Strategy Logic
The strategy mainly calculates the five lines of the ichimoku cloud indicator based on the following formulas:
Conversion Line: 9-period average of the highest high and lowest low
Base Line: 26-period average of the highest high and lowest low
Leading Span 1: average of the conversion line and base line
Leading Span 2: 52-period average of the highest high and lowest low
Lagging Span: closing price plotted 26 periods behind
When the closing price is above the cloud, it is considered an upward trend and a buy signal is generated. When the closing price is below the cloud, it is considered a downward trend and a sell signal is generated.
Specifically, the strategy implements this logic through the following steps:
Calculate the conversion line, base line, leading span 1, and leading span 2
Plot the lagging span of the closing price 26 periods behind
Check if the closing price is above the cloud (leading span 1 and 2), generate buy signal if true
Check if the closing price is below the cloud, generate sell signal if true
Enter trades on buy/sell signals based on strategy settings
Advantage Analysis
The main advantages of this strategy are:
Using the ichimoku cloud can effectively identify trends and generate signals along the trend direction, avoiding unnecessary trades in range-bound markets.
The calculation parameters are optimized for daily trading.
Using both leading span 1 and 2 combines multiple signals to filter out false signals.
The lagging span delay helps reduce risk of immediate pullback after cloud breakout.
Simple and clear logic, easy to understand and implement.
No other indicators needed, complete trend following system.
Risk Analysis
There are some risks to consider:
The cloud may fail in certain market conditions, generating incorrect signals.
If parameters are not adapted to changing market dynamics, it weakens the system.
The fixed lagging span delay may miss some opportunities.
Still cannot completely avoid whipsaws.
There is some time lag, unable to capture quick reversals.
Cannot differentiate major trends vs shorter corrections, may cause losses.
Improvement Areas
Some ways to improve the strategy:
Optimize parameters like conversion line for different market conditions.
Add trend filtering indicators to confirm strength and direction.
Implement stop loss and take profit to control loss per trade.
Only take cloud breakout signals with high volume.
Use different parameter sets based on market regime.
Add machine learning to auto-optimize parameters.
Consider dynamic lagging span instead of fixed delay.
Summary
Overall, this ichimoku cloud strategy implements basic trend following rules, although improvements can be made. The core logic is sound, parameters optimized, good baseline algo trading strategy. With further cloud parameter enhancement, adding filters and risk controls, it can become a very practical quantitative trading system.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 9 | Conversion Line Periods |
| v_input_2 | 26 | Base Line Periods |
| v_input_3 | 52 | Lagging Span 2 Periods |
| v_input_4 | 26 | Displacement |
Source Pine Script
/*backtest
start: 2023-09-30 00:00:00
end: 2023-10-07 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(title="Ichimoku Cloud", shorttitle="Ichimoku", overlay=true, commission_type=strategy.commission.percent,commission_value=0.075, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
basePeriods = input(26, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
displacement = input(26, minval=0, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#0496ff, title="Conversion Line")
plot(baseLine, color=#991515, title="Base Line")
plot(close, offset = -displacement, color=#459915, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement, color=color.green,
title="Lead 1")
p2 = plot(leadLine2, offset = displacement, color=color.red,
title="Lead 2")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red)
buy = close > leadLine1[26] and close > leadLine2[26]
sell = close < leadLine1[26] and close < leadLine2[26]
strategy.entry("Buy", strategy.long, when = buy)
strategy.entry("Sell", strategy.short, when = sell)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-08. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Ichimoku-Cloud-Trading-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Ichimoku Stop Loss StrategyPine Script · Breakout · 1d
- Multi Indicator Short Term Algorithmic Trading StrategyPine Script · Breakout · 4h
- The Octagon Cloud Tracing StrategyPine Script · Breakout · 1d
- Ichimoku Breakout StrategyPine Script · Breakout · 1d
- Integrated Ichimoku Keltner Trading System Based on Moving Average StrategyPine Script · Breakout · 1h
- Ichimoku Cloud Market Analysis StrategyPine Script · Breakout · 5m