Ichimoku Cloud with MACD and Trailing Stop Loss (by Coinrule)
Dec 2, 2022

The Ichimoku Cloud with MACD and Trailing Stop Loss indicator provides a comprehensive trend-following framework by merging the Ichimoku Kinko Hyo system with MACD momentum and dynamic risk management. It aims to identify high-probability trend entries while protecting capital through an automated trailing stop-loss mechanism.
Usage
The Usage section describes how the script can be used, particularly in identifying trend alignment and managing exits.
- Long Entries: A long signal is generated when the Tenkan-Sen is above the Kijun-Sen, the Chikou-Span is above the price from 26 periods ago, the current price is trading above the Kumo Cloud, and the MACD line crosses above the signal line.
- Short Entries: A short signal occurs when the Tenkan-Sen is below the Kijun-Sen, the Chikou-Span is below the price from 26 periods ago, the price is below the Kumo Cloud, and the MACD line crosses below the signal line.
- Exit Strategy: The script employs a trailing stop-loss based on a percentage of the price. As the price moves in a favorable direction, the stop level adjusts upward (for longs) or downward (for shorts) to lock in profits, triggering an exit if the price retraces by the specified percentage.
Details
The script integrates the five primary lines of the Ichimoku Cloud—Tenkan-Sen (9-period average), Kijun-Sen (26-period average), Senkou Span A (average of Tenkan and Kijun), Senkou Span B (52-period average), and Chikou Span (lagging line)—to define the "Cloud" (Kumo). This cloud acts as a dynamic support and resistance zone. By adding the MACD (12, 26, 9), the tool filters out low-momentum Ichimoku signals, requiring a momentum confirmation before an entry is valid. The trailing stop logic ensures that the strategy remains reactive to market volatility rather than relying on fixed price targets.
Settings
- Show Date Range: Toggles whether the strategy logic is restricted to a specific time window.
- Tenkan-Sen Bars: Determines the period for the short-term conversion line.
- Kijun-Sen Bars: Determines the period for the medium-term base line.
- Senkou-Span B Bars: Determines the period for the long-term cloud boundary.
- Chikou-Span Offset: Sets the number of bars to lag the closing price for trend confirmation.
- Senkou-Span Offset: Sets the number of bars to project the cloud into the future.
- Long Entry: Enables or disables the execution of long positions.
- Short Entry: Enables or disables the execution of short positions.
- Trail Long Loss (%): Sets the percentage distance for the trailing stop-loss on long trades.
- Trail Short Loss (%): Sets the percentage distance for the trailing stop-loss on short trades.
FAQ
How do I interpret the Cloud color? The cloud is green when Senkou-Span A is above Senkou-Span B, indicating a bullish bias, and red when Senkou-Span B is higher, indicating a bearish bias.
Can I change the MACD parameters? In this version, the MACD utilizes standard 12, 26, and 9 settings for EMA calculation and signal smoothing to ensure consistent trend identification.
How do I access the Ichimoku Cloud with MACD and Trailing Stop Loss? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Unlock Unlimited Access to the LuxAlgo Library
Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

