Strategy vault / Trend following
Dynamic Ichimoku Moving Average Crossover Trend Switching Strategy
This strategy is a dynamic trend-following trading system based on the Ichimoku Cloud indicator. The core concept is to identify market trend changes by monitoring the crossover between the Conversion Line…

Overview
This strategy is a dynamic trend-following trading system based on the Ichimoku Cloud indicator. The core concept is to identify market trend changes by monitoring the crossover between the Conversion Line (Tenkan-sen) and Base Line (Kijun-sen), executing position switches between long and short at appropriate times. The strategy combines the reliability of traditional Ichimoku indicators with the flexibility of modern quantitative trading.
Strategy Principle
The strategy operates based on the following key elements:
- Calculates Conversion and Base Lines using 9-period and 26-period high-low averages
- Determines market trends through the direction of Conversion and Base Line crossovers
- Generates golden cross signals for long entries or position switches when Conversion Line crosses above Base Line
- Generates dead cross signals for short entries or position switches when Conversion Line crosses below Base Line
- Automatically determines position switching needs based on current position status
Strategy Advantages
- Stable and reliable signal system: Ichimoku indicator shows good reliability in trending markets
- Dynamic position management: Strategy automatically adjusts position direction based on market conditions
- Reasonable risk control: Confirms trends through moving average crossovers, reducing false breakout losses
- Clear operational logic: Well-defined entry and exit signals, suitable for backtesting and live trading
- High adaptability: Strategy parameters can be optimized for different market characteristics
Strategy Risks
- Choppy market risk: May generate frequent false signals in sideways markets
- Slippage risk: May face significant slippage losses in fast-moving markets
- Trend delay risk: Moving average crossover signals have inherent lag
- Money management risk: Requires proper control of position sizing
- Market environment risk: Strategy performance may vary under different market conditions
Strategy Optimization Directions
- Incorporate volume indicators: Confirm signal reliability using volume data
- Add trend filters: Filter false signals by combining other technical indicators
- Optimize parameter selection: Dynamically adjust moving average periods based on market characteristics
- Improve stop-loss mechanism: Implement dynamic stop-losses for risk control
- Enhanced market condition assessment: Adjust strategy parameters based on volatility metrics
Summary
This strategy captures market trend transitions through Ichimoku indicator's Conversion and Base Line crossovers, featuring clear logic and easy implementation. Its strength lies in automatically adapting to market changes and timely adjusting position direction. While inherent risks exist, the strategy can achieve stable returns in trending markets through proper optimization and risk control measures. Investors are advised to optimize strategy parameters based on market characteristics and individual risk preferences in practical applications.
Source Pine Script
/*backtest
start: 2024-02-19 00:00:00
end: 2025-02-16 08:00:00
period: 4h
basePeriod: 4h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pyoungil0842
//@version=6
strategy("Ichimoku Crossover Strategy with Switching", overlay=true)
// 일목균형표의 요소 계산
tenkanLength = input(9, title="전환선 기간")
kijunLength = input(26, title="기준선 기간")
tenkan = ta.sma(ta.highest(high, tenkanLength) + ta.lowest(low, tenkanLength), 2)
kijun = ta.sma(ta.highest(high, kijunLength) + ta.lowest(low, kijunLength), 2)
// 현재 캔들에서 교차 신호 확인
goldenCross = (tenkan > kijun) and (tenkan[1] <= kijun[1]) // 전환선이 기준선을 상향 돌파
deadCross = (tenkan < kijun) and (tenkan[1] >= kijun[1]) // 전환선이 기준선을 하향 돌파
// 현재 포지션 상태
isLong = strategy.position_size > 0 // 롱 포지션 여부
isShort = strategy.position_size < 0 // 숏 포지션 여부
// 전략 매수/매도 조건
if (goldenCross)
if (isShort) // 숏 포지션이 있을 경우 스위칭
strategy.close("Short")
strategy.entry("Long", strategy.long)
else if (strategy.position_size == 0) // 포지션이 없을 경우 신규 진입
strategy.entry("Long", strategy.long)
if (deadCross)
if (isLong) // 롱 포지션이 있을 경우 스위칭
strategy.close("Long")
strategy.entry("Short", strategy.short)
else if (strategy.position_size == 0) // 포지션이 없을 경우 신규 진입
strategy.entry("Short", strategy.short)
// 차트에 전환선과 기준선 표시
plot(tenkan, color=color.blue, title="전환선")
plot(kijun, color=color.red, title="기준선")
Published by ChaoZhang on the FMZ strategy square · last modified 2025-02-18. 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/Dynamic-Ichimoku-Moving-Average-Crossover-Trend-Switching-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
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Triple Supertrend Ichimoku Cloud Quantitative Trading StrategyPine Script · Trend following · 1d
- Ichimoku Trend Following StrategyPine Script · Trend following · 1d
- TrendHunter w MF Multi Timeframe Trend StrategyPine Script · Trend following · 1h
- Dynamic Trailing Stop Optimization Strategy Based on Ichimoku CloudPine Script · Trend following · 1d
- Ichimoku Kinko Hyo indicator Balancing Trend StrategyPine Script · Trend following · 3m