
The Momentum Trading Multi-Color Candle Recognition Quantitative Strategy is a price action-based trading system that utilizes color-coded candlesticks to identify short-term directional trading opportunities. This strategy is applicable across any timeframe, particularly performing well on 1-minute, 5-minute, and 15-minute charts. The core logic relies on specific color transition patterns, where yellow candles serve as signal candles, green or red candles act as entry confirmations, and blue candles function as early exit warning signals. This visual momentum strategy provides traders with clear entry and exit rules, helping to capture short-term market fluctuations.
The core principle of this strategy is to predict price trend continuation or reversal by observing color changes in candlesticks. Specifically:
Entry Logic:
Candle Color Definitions:
Exit Logic:
The strategy is implemented through Pine Script, using boolean variables to track trade status and triggering entry and exit signals based on candle color changes.
Simplicity and Intuitiveness: Using color coding makes the strategy easy to understand and execute, reducing the complexity of trading decisions.
High Adaptability: Can be applied to multiple timeframes and markets, providing good versatility.
Clear Rule System: Entry, exit, and stop-loss rules are clearly defined, reducing uncertainty from subjective judgment.
Integrated Risk Management: Built-in stop-loss mechanisms and optional early exit features help protect capital and lock in profits.
Momentum Capture Capability: Strategy design focuses on capturing short-term price momentum, helping to enter the market in the early stages of trend formation.
Customizability: Code structure allows traders to modify candle color conditions according to their needs, enhancing strategy flexibility.
Visual Feedback: By plotting buy and sell signal markers, it provides intuitive visual feedback, helping traders evaluate the quality of past signals.
False Signal Risk: In sideways or highly volatile markets, frequent false signals may occur, leading to consecutive losing trades. Mitigation: Additional filtering conditions can be added, such as volatility indicators or trend confirmation.
Parameter Sensitivity: Strategy performance may be highly sensitive to the specific parameters defining candle colors. Solution: Conduct comprehensive parameter optimization and backtesting to find parameter settings that perform consistently across different market conditions.
Overtrading: As the strategy is based on short-term price movements, it may lead to overtrading and increased transaction costs. Mitigation: Add time filters or set minimum holding time restrictions.
Stop-Loss Trigger Risk: In highly volatile markets, stop-losses may be frequently triggered, followed by price returning to the original direction. Solution: Consider using ATR-based dynamic stop-losses or optimize the stop-loss position calculation method.
Lack of Fundamental Considerations: Pure technical strategies ignore the impact of fundamental factors on price. Improvement: Incorporate filters for macroeconomic data releases or important news events.
Backtest Bias: Simulated color conditions may not accurately reflect actual trading environments. Countermeasure: Use actual trading data for forward testing and implement the strategy gradually.
Enhanced Signal Filtering:
isUptrend = close > sma(close, 50) and use as an additional condition for buy signalsOptimize Stop-Loss Mechanism:
atr_value = ta.atr(14) and dynamic_sl = isLong ? entryPrice - atr_value * 2 : entryPrice + atr_value * 2Improve Candle Recognition Logic:
Time Filtering:
validTradingHour = (hour >= 9 and hour < 16)Quantify Exit Criteria:
take_profit_level = isLong ? entryPrice * 1.02 : entryPrice * 0.98Machine Learning Integration:
Risk Management Enhancement:
position_size = (account_balance * risk_percent) / (close - stopLoss)The Momentum Trading Multi-Color Candle Recognition Quantitative Strategy provides a visually intuitive, rule-based trading method particularly suitable for capturing short-term price momentum. The strategy identifies signals through color-coded candlesticks, offering advantages of simplicity, clear rules, and integrated risk management. However, the strategy also faces risks such as false signals, overtrading, and parameter sensitivity.
By enhancing signal filtering, optimizing stop-loss mechanisms, improving candle recognition logic, and implementing more sophisticated exit strategies, the robustness and performance of the strategy can be significantly improved. In particular, integrating trend confirmation indicators and volatility filters will help reduce false signals, while dynamic stop-losses and partial profit mechanisms can improve risk-reward characteristics.
For traders seeking a visual, rule-based trading system, this multi-color candle strategy provides a solid foundation that can be further customized and optimized according to individual risk preferences and market conditions.
/*backtest
start: 2024-05-27 00:00:00
end: 2025-05-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("Color Candle Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
/// === INPUTS === ///
useEarlyExit = input.bool(true, "Enable Early Exit (Blue Candle)")
showSignals = input.bool(true, "Show Buy/Sell Signals")
// Simulated Color Conditions (Replace with your real candle condition logic)
isYellow = close > open and close[1] < open[1] // placeholder for Yellow
isGreen = close > open and close > high[1] // placeholder for Green
isRed = close < open and close < low[1] // placeholder for Red
isBlue = close < open and volume > volume[1]*1.5 // placeholder for Blue
/// === STATE TRACKING === ///
var bool inTrade = false
var bool isLong = false
var float entryPrice = na
var float stopLoss = na
/// === ENTRY LOGIC === ///
buySignal = isGreen and isYellow[1]
sellSignal = isRed and isYellow[1]
/// === PLOT ENTRIES === ///
if (buySignal and not inTrade)
strategy.entry("BUY", strategy.long)
inTrade := true
isLong := true
entryPrice := close
stopLoss := math.min(low[1], low)
strategy.exit("SL/TP Buy", from_entry="BUY", stop=stopLoss)
if (sellSignal and not inTrade)
strategy.entry("SELL", strategy.short)
inTrade := true
isLong := false
entryPrice := close
stopLoss := math.max(high[1], high)
strategy.exit("SL/TP Sell", from_entry="SELL", stop=stopLoss)
/// === EXIT CONDITIONS === ///
exitOnOpposite = (isLong and (isYellow or isRed)) or (not isLong and (isYellow or isGreen))
earlyExit = useEarlyExit and isBlue
if (inTrade and (exitOnOpposite or earlyExit))
strategy.close("BUY")
strategy.close("SELL")
inTrade := false
/// === PLOT SIGNAL MARKERS === ///
plotshape(showSignals and buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(showSignals and sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")