0bps

Strategy vault / Trend following

Ichimoku Trading Strategy

This LONG-ONLY strategy uses the Ichimoku Kinko Hyo system for trades. It combines multiple Ichimoku factors to go long when criteria are met. The trading logic is: 1. Calculate conversion, base line, leading spans 1…

Author
ChaoZhang
Complexity
Starter · 52 lines
Parameters
5
Backtest bar
2h · intraday
Tested on
BTC/USDT · spot

Strategy Logic

This LONG-ONLY strategy uses the Ichimoku Kinko Hyo system for trades. It combines multiple Ichimoku factors to go long when criteria are met.

The trading logic is:

  1. Calculate conversion, base line, leading spans 1 & 2

  2. Consider long when close is above cloud and cloud is rising, with conversion above base line

  3. Additionally, lagging span must be above cloud and price for uptrend confirmation

  4. When all criteria met, go long

  5. If lagging span falls below price or cloud, close long

The strategy utilizes Ichimoku's indicators to confirm trend, with the cloud as dynamic stops for risk control.

Advantages

  • Ichimoku synthesizes multiple factors for trend determination

  • Dynamic stops to maximize profit locking

  • Simple and clear rules for easy implementation

Risks

  • Ichimoku is slow and may miss opportunities

  • Careful optimization of lookback periods needed

  • LONG only, so good short chances missed

Summary

This strategy leverages Ichimoku's synthesis of indicators to define trend direction. With optimized parameters, it provides a simple long-only system. But limitations in lag and being LONG-only require caution.

Parameters

NameDefaultWhat it controls
v_input_120Conversion Line Length
v_input_260Base Line Length
v_input_3120Leading Span B Length
v_input_430Displacement
v_input_5trueStoploss (% below cloud)

Source Pine Script

/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(title="Ichimoku Cloud", shorttitle="Doubled Ichimoku", overlay=true, initial_capital=1000, default_qty_value=100, default_qty_type=strategy.percent_of_equity)
conversionPeriods = input(20, minval=1, title="Conversion Line Length")
basePeriods = input(60, minval=1, title="Base Line Length")
laggingSpan2Periods = input(120, minval=1, title="Leading Span B Length")
displacement = input(30, minval=1, title="Displacement")
Stoploss = input(1, minval=0.1, title="Stoploss (% below cloud)") 
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")

p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
	 title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
	 title="Leading Span B")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))

bool TKcross = conversionLine > baseLine
bool aboveCloud = close > leadLine1 and close > leadLine2
bool greenCloud = leadLine1 > leadLine2
bool lagLong = close > leadLine1[2*displacement+1] and close > leadLine2[2*displacement+1] and close > close[displacement]
bool longCondition = false
bool close_trade = crossover(leadLine1[displacement], close) or crossover (leadLine2[displacement], close) or close < close[displacement] or crossover(baseLine, close)
var position_count = 0 

if (TKcross and aboveCloud and greenCloud and lagLong and position_count==0)
    position_count = 1
    strategy.entry(id="buy", long=true)

if (close_trade)
    strategy.close_all()
   // strategy.entry(id="sell", long=false)
    position_count = 0

    
//if (longCondition)
   
//    strategy.close("long", when=exit_trade)
//    strategy.exit("exit","long",stop=stop_level,limit=profit_level)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-14. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Ichimoku-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open