OPEN-SOURCE SCRIPT
Ichimoku 5 Rules Backtest

ICHIMOKU 5/5 BACKTEST STRATEGY
This strategy is a rule-based, long-only backtesting framework designed specifically for the 1-hour timeframe.
Its purpose is to evaluate the historical behavior of a five-condition Ichimoku-based setup under predefined risk, reward, and holding-time rules.
The strategy does not attempt to predict future prices. It is designed to test whether a clearly defined technical setup produces repeatable historical outcomes across a sufficiently large sample of trades.
HOW THE STRATEGY WORKS
A potential long setup requires all five conditions to be simultaneously satisfied and confirmed.
1. CHIKOU CONFIRMATION
Current price must be above the price from 26 bars ago.
This condition is used as a historical price-structure confirmation.
2. TENKAN / KIJUN STRUCTURE
Tenkan-sen must be above Kijun-sen.
This represents bullish short-term versus medium-term Ichimoku structure.
3. MACD MOMENTUM STRUCTURE
The strategy evaluates bullish MACD and/or Signal Line divergence or convergence using confirmed price pivot lows.
The pivot comparison can identify:
- Lower Low in price with Higher Low in momentum
- Higher Low in price with Higher Low in momentum
The MACD, Signal Line, or both can be selected through the strategy inputs.
Because pivots require right-side confirmation bars, this condition only becomes available after the relevant pivot has been confirmed.
4. KUMO BREAKOUT + PULLBACK CONDITION
Price must be above the relevant Kumo reference after having traded below or inside the cloud during the selected historical lookback period.
This condition is intended to identify a transition from weaker price structure into a confirmed position above the cloud.
5. BULLISH KUMO
Senkou Span A must be above Senkou Span B.
This represents bullish future-cloud structure.
ENTRY LOGIC
A trade is generated only when a NEW confirmed 5/5 setup appears.
If all five conditions remain true for several consecutive bars, the strategy does not repeatedly generate additional entries.
Pyramiding is disabled.
The setup is confirmed using completed bars.
Because process_orders_on_close is disabled, a confirmed signal is submitted after the signal bar closes and is normally filled according to TradingView's broker-emulator execution model on the following bar.
DEFAULT CAPITAL AND POSITION SETTINGS
Initial capital:
USD 3,000
Position size:
10% of current equity
Pyramiding:
0
The strategy is intended to simulate relatively small position exposure while separating position size from the maximum intended capital risk.
RISK MANAGEMENT
Default maximum intended risk per trade:
1% of current equity
Default target:
3.5R
The initial risk amount is calculated from current strategy equity.
The stop distance is then derived from:
Initial Risk Cash / Position Size
For a long trade:
Stop Price =
Entry Price - Risk Per Share
Target Price =
Entry Price + (Risk Per Share × Reward/Risk Multiple)
The default reward/risk multiple is 3.5R but can be modified through the strategy inputs.
TRADING COSTS
The strategy uses a fixed commission of:
USD 0.10 per executed order
Under the normal one-entry / one-exit structure:
Entry commission:
USD 0.10
Exit commission:
USD 0.10
Approximate total commission for a completed trade:
USD 0.20
The commission is fixed per order and does not vary with position value.
The TRIM marker is visual only and therefore does not generate an additional order or commission.
Slippage and bid/ask spread can vary substantially by instrument, liquidity, market conditions, and order type. They should be considered when interpreting historical results. Users should apply assumptions appropriate to the instrument being tested.
MAXIMUM HOLDING TIME
Default maximum holding period:
15 trading sessions
Default 1-hour bars per session:
7
Equivalent maximum:
105 one-hour bars
If neither the stop nor the target has been reached by the maximum holding period, the position is closed using a TIME EXIT.
Both values can be modified through the strategy inputs.
TRIM REFERENCE
The strategy includes an optional TRIM marker intended to identify when price has completed a selected percentage of the theoretical Entry-to-Target distance.
Default TRIM level:
75%
The percentage is configurable.
For example, with a 3.5R target:
75% × 3.5R = 2.625R
Therefore, under the default parameters, the TRIM reference corresponds to approximately +2.625R from the entry.
IMPORTANT:
TRIM is a visual reference only.
It does NOT:
- reduce the position
- execute a partial exit
- modify the stop
- change the profit target
- affect strategy performance
- generate additional commissions
TRIM GAP HANDLING
Two different situations are considered.
NORMAL PRICE MOVEMENT
If price trades normally through the calculated TRIM level, the TRIM label is placed at the theoretical TRIM price.
GAP ABOVE TRIM
If the market opens above the calculated TRIM level, the label is placed at the opening price of that bar.
This is intended to avoid visually marking an execution at a theoretical price that was skipped by the gap.
The marker remains informational only.
BACKTEST TABLE
The strategy includes an on-chart statistical table containing:
- Closed Trades
- Wins
- Losses
- Win Rate
- Profit Factor
- Expectancy
- Net P&L
- ROI
- Maximum Drawdown
- Average Holding Period
- Target Exits
- Stop Exits
- Time Exits
- Realized R Distribution
- Mean R
- Standard Deviation of R
REALIZED R DISTRIBUTION
Each completed trade is measured relative to its initial planned risk.
Realized R is calculated as:
Trade Profit / Initial Risk Cash
For visualization, outcomes are grouped into 0.5R distribution ranges.
The distribution includes:
<= -1.0R
-0.5R
0.0R
+0.5R
+1.0R
+1.5R
+2.0R
+2.5R
+3.0R
>= +3.5R
The distribution buckets are rounded for display purposes only.
Mean R and Standard Deviation are calculated from the actual realized R values rather than from the rounded distribution buckets.
EXPECTANCY
Mean R represents the average realized R-multiple produced by the completed trades in the historical sample.
It is displayed as the strategy's historical expectancy per trade.
A positive historical expectancy does not imply that future expectancy will remain positive.
STANDARD DEVIATION
Standard Deviation measures the dispersion of individual realized R outcomes around the historical Mean R.
It is included to provide additional context regarding the variability of strategy outcomes.
The calculation does not assume that future returns will follow a normal distribution.
SAMPLE SIZE
The strategy includes a visual sample-size classification.
LOW:
Fewer than 50 completed trades
PRELIM.:
50 to 99 completed trades
VALID:
100 or more completed trades
IMPORTANT:
The term VALID refers only to the strategy's predefined minimum sample-size threshold.
It does NOT mean that the strategy has been statistically validated, that its results are reliable in every market, or that future profitability is expected.
Sample size should always be interpreted together with timeframe, instrument, market regime, expectancy, drawdown, dispersion, and other statistical characteristics.
TIMEFRAME
This strategy is designed specifically for:
1-hour charts
The script validates the chart timeframe and is not intended to be used unchanged on other timeframes.
Testing the same logic on another timeframe may produce materially different results.
CHART TYPE
The strategy is intended for use on standard price candles.
Results obtained from synthetic or non-standard chart types may not represent executable market prices and should not be interpreted in the same way as results obtained from standard OHLC market data.
ORIGINAL PURPOSE OF THE SCRIPT
This script is not intended to reproduce a standard Ichimoku indicator.
Its purpose is to combine a specific five-condition decision framework with:
- confirmed Ichimoku structure
- pivot-based MACD momentum analysis
- explicit equity-based risk modeling
- fixed reward/risk targeting
- maximum holding-time rules
- gap-aware TRIM visualization
- realized R distribution
- expectancy analysis
- outcome dispersion
- exit-type classification
- sample-size monitoring
The strategy is primarily a research and backtesting tool for studying the historical behavior of this specific rules-based setup.
BACKTEST LIMITATIONS
Historical results are simulations and do not represent actual trading performance.
Real-world results can differ due to factors including:
- slippage
- bid/ask spread
- commissions
- liquidity
- market impact
- order type
- order priority
- partial fills
- trading halts
- gaps
- broker execution
- exchange rules
- data quality
- corporate actions
- symbol history
- market regime changes
Historical OHLC bars also do not always reveal the exact sequence in which prices moved inside each bar.
When multiple relevant price levels occur within the same historical bar, TradingView's broker emulator determines fills according to the information and execution assumptions available to the strategy.
For this reason, individual historical fills should not be interpreted as a reconstruction of actual tick-by-tick execution.
REPAINTING AND CONFIRMATION
Trade setups are based on confirmed bars.
The momentum component uses confirmed pivots. Because pivot detection requires bars to the right of the pivot, a pivot is recognized only after its confirmation period has elapsed.
This confirmation delay is part of the strategy logic and should be considered when interpreting signals.
INTERPRETING RESULTS
Historical performance should not be evaluated from a single symbol, isolated market period, or individual trade.
A more robust evaluation should consider:
- a sufficiently large trade sample
- different symbols
- different market environments
- trending and non-trending periods
- drawdown
- realized R distribution
- expectancy
- outcome dispersion
- transaction costs
- execution assumptions
Changing parameters can materially alter historical results and may introduce overfitting.
Parameters should therefore be selected based on a defined trading hypothesis rather than solely because they improve historical performance.
DISCLAIMER
This strategy is provided for educational, analytical, and research purposes only.
It is not financial advice.
It does not constitute an offer, solicitation, recommendation, or instruction to buy or sell any financial instrument.
Historical performance does not guarantee future results.
All trading and investment decisions, including position sizing and risk management, remain the sole responsibility of the user.
This strategy is a rule-based, long-only backtesting framework designed specifically for the 1-hour timeframe.
Its purpose is to evaluate the historical behavior of a five-condition Ichimoku-based setup under predefined risk, reward, and holding-time rules.
The strategy does not attempt to predict future prices. It is designed to test whether a clearly defined technical setup produces repeatable historical outcomes across a sufficiently large sample of trades.
HOW THE STRATEGY WORKS
A potential long setup requires all five conditions to be simultaneously satisfied and confirmed.
1. CHIKOU CONFIRMATION
Current price must be above the price from 26 bars ago.
This condition is used as a historical price-structure confirmation.
2. TENKAN / KIJUN STRUCTURE
Tenkan-sen must be above Kijun-sen.
This represents bullish short-term versus medium-term Ichimoku structure.
3. MACD MOMENTUM STRUCTURE
The strategy evaluates bullish MACD and/or Signal Line divergence or convergence using confirmed price pivot lows.
The pivot comparison can identify:
- Lower Low in price with Higher Low in momentum
- Higher Low in price with Higher Low in momentum
The MACD, Signal Line, or both can be selected through the strategy inputs.
Because pivots require right-side confirmation bars, this condition only becomes available after the relevant pivot has been confirmed.
4. KUMO BREAKOUT + PULLBACK CONDITION
Price must be above the relevant Kumo reference after having traded below or inside the cloud during the selected historical lookback period.
This condition is intended to identify a transition from weaker price structure into a confirmed position above the cloud.
5. BULLISH KUMO
Senkou Span A must be above Senkou Span B.
This represents bullish future-cloud structure.
ENTRY LOGIC
A trade is generated only when a NEW confirmed 5/5 setup appears.
If all five conditions remain true for several consecutive bars, the strategy does not repeatedly generate additional entries.
Pyramiding is disabled.
The setup is confirmed using completed bars.
Because process_orders_on_close is disabled, a confirmed signal is submitted after the signal bar closes and is normally filled according to TradingView's broker-emulator execution model on the following bar.
DEFAULT CAPITAL AND POSITION SETTINGS
Initial capital:
USD 3,000
Position size:
10% of current equity
Pyramiding:
0
The strategy is intended to simulate relatively small position exposure while separating position size from the maximum intended capital risk.
RISK MANAGEMENT
Default maximum intended risk per trade:
1% of current equity
Default target:
3.5R
The initial risk amount is calculated from current strategy equity.
The stop distance is then derived from:
Initial Risk Cash / Position Size
For a long trade:
Stop Price =
Entry Price - Risk Per Share
Target Price =
Entry Price + (Risk Per Share × Reward/Risk Multiple)
The default reward/risk multiple is 3.5R but can be modified through the strategy inputs.
TRADING COSTS
The strategy uses a fixed commission of:
USD 0.10 per executed order
Under the normal one-entry / one-exit structure:
Entry commission:
USD 0.10
Exit commission:
USD 0.10
Approximate total commission for a completed trade:
USD 0.20
The commission is fixed per order and does not vary with position value.
The TRIM marker is visual only and therefore does not generate an additional order or commission.
Slippage and bid/ask spread can vary substantially by instrument, liquidity, market conditions, and order type. They should be considered when interpreting historical results. Users should apply assumptions appropriate to the instrument being tested.
MAXIMUM HOLDING TIME
Default maximum holding period:
15 trading sessions
Default 1-hour bars per session:
7
Equivalent maximum:
105 one-hour bars
If neither the stop nor the target has been reached by the maximum holding period, the position is closed using a TIME EXIT.
Both values can be modified through the strategy inputs.
TRIM REFERENCE
The strategy includes an optional TRIM marker intended to identify when price has completed a selected percentage of the theoretical Entry-to-Target distance.
Default TRIM level:
75%
The percentage is configurable.
For example, with a 3.5R target:
75% × 3.5R = 2.625R
Therefore, under the default parameters, the TRIM reference corresponds to approximately +2.625R from the entry.
IMPORTANT:
TRIM is a visual reference only.
It does NOT:
- reduce the position
- execute a partial exit
- modify the stop
- change the profit target
- affect strategy performance
- generate additional commissions
TRIM GAP HANDLING
Two different situations are considered.
NORMAL PRICE MOVEMENT
If price trades normally through the calculated TRIM level, the TRIM label is placed at the theoretical TRIM price.
GAP ABOVE TRIM
If the market opens above the calculated TRIM level, the label is placed at the opening price of that bar.
This is intended to avoid visually marking an execution at a theoretical price that was skipped by the gap.
The marker remains informational only.
BACKTEST TABLE
The strategy includes an on-chart statistical table containing:
- Closed Trades
- Wins
- Losses
- Win Rate
- Profit Factor
- Expectancy
- Net P&L
- ROI
- Maximum Drawdown
- Average Holding Period
- Target Exits
- Stop Exits
- Time Exits
- Realized R Distribution
- Mean R
- Standard Deviation of R
REALIZED R DISTRIBUTION
Each completed trade is measured relative to its initial planned risk.
Realized R is calculated as:
Trade Profit / Initial Risk Cash
For visualization, outcomes are grouped into 0.5R distribution ranges.
The distribution includes:
<= -1.0R
-0.5R
0.0R
+0.5R
+1.0R
+1.5R
+2.0R
+2.5R
+3.0R
>= +3.5R
The distribution buckets are rounded for display purposes only.
Mean R and Standard Deviation are calculated from the actual realized R values rather than from the rounded distribution buckets.
EXPECTANCY
Mean R represents the average realized R-multiple produced by the completed trades in the historical sample.
It is displayed as the strategy's historical expectancy per trade.
A positive historical expectancy does not imply that future expectancy will remain positive.
STANDARD DEVIATION
Standard Deviation measures the dispersion of individual realized R outcomes around the historical Mean R.
It is included to provide additional context regarding the variability of strategy outcomes.
The calculation does not assume that future returns will follow a normal distribution.
SAMPLE SIZE
The strategy includes a visual sample-size classification.
LOW:
Fewer than 50 completed trades
PRELIM.:
50 to 99 completed trades
VALID:
100 or more completed trades
IMPORTANT:
The term VALID refers only to the strategy's predefined minimum sample-size threshold.
It does NOT mean that the strategy has been statistically validated, that its results are reliable in every market, or that future profitability is expected.
Sample size should always be interpreted together with timeframe, instrument, market regime, expectancy, drawdown, dispersion, and other statistical characteristics.
TIMEFRAME
This strategy is designed specifically for:
1-hour charts
The script validates the chart timeframe and is not intended to be used unchanged on other timeframes.
Testing the same logic on another timeframe may produce materially different results.
CHART TYPE
The strategy is intended for use on standard price candles.
Results obtained from synthetic or non-standard chart types may not represent executable market prices and should not be interpreted in the same way as results obtained from standard OHLC market data.
ORIGINAL PURPOSE OF THE SCRIPT
This script is not intended to reproduce a standard Ichimoku indicator.
Its purpose is to combine a specific five-condition decision framework with:
- confirmed Ichimoku structure
- pivot-based MACD momentum analysis
- explicit equity-based risk modeling
- fixed reward/risk targeting
- maximum holding-time rules
- gap-aware TRIM visualization
- realized R distribution
- expectancy analysis
- outcome dispersion
- exit-type classification
- sample-size monitoring
The strategy is primarily a research and backtesting tool for studying the historical behavior of this specific rules-based setup.
BACKTEST LIMITATIONS
Historical results are simulations and do not represent actual trading performance.
Real-world results can differ due to factors including:
- slippage
- bid/ask spread
- commissions
- liquidity
- market impact
- order type
- order priority
- partial fills
- trading halts
- gaps
- broker execution
- exchange rules
- data quality
- corporate actions
- symbol history
- market regime changes
Historical OHLC bars also do not always reveal the exact sequence in which prices moved inside each bar.
When multiple relevant price levels occur within the same historical bar, TradingView's broker emulator determines fills according to the information and execution assumptions available to the strategy.
For this reason, individual historical fills should not be interpreted as a reconstruction of actual tick-by-tick execution.
REPAINTING AND CONFIRMATION
Trade setups are based on confirmed bars.
The momentum component uses confirmed pivots. Because pivot detection requires bars to the right of the pivot, a pivot is recognized only after its confirmation period has elapsed.
This confirmation delay is part of the strategy logic and should be considered when interpreting signals.
INTERPRETING RESULTS
Historical performance should not be evaluated from a single symbol, isolated market period, or individual trade.
A more robust evaluation should consider:
- a sufficiently large trade sample
- different symbols
- different market environments
- trending and non-trending periods
- drawdown
- realized R distribution
- expectancy
- outcome dispersion
- transaction costs
- execution assumptions
Changing parameters can materially alter historical results and may introduce overfitting.
Parameters should therefore be selected based on a defined trading hypothesis rather than solely because they improve historical performance.
DISCLAIMER
This strategy is provided for educational, analytical, and research purposes only.
It is not financial advice.
It does not constitute an offer, solicitation, recommendation, or instruction to buy or sell any financial instrument.
Historical performance does not guarantee future results.
All trading and investment decisions, including position sizing and risk management, remain the sole responsibility of the user.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Setup + Risk Management + 1% better daily = Consistency. 📈
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Setup + Risk Management + 1% better daily = Consistency. 📈
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.