This strategy is a bidirectional trading system based on candlestick absorption patterns. It identifies market absorption patterns by analyzing the direction, amplitude, and volume relationships of adjacent candlesticks, executing trades when conditions are met. The strategy employs percentage-based money management with complete entry and exit logic.
The core logic is based on three key conditions:
When these three conditions are met simultaneously, the strategy determines the trading direction based on the latest candlestick: long for bullish candles, short for bearish ones. The strategy uses full position trading and tracks positions through state variables.
This strategy constructs a complete trading system through multi-dimensional analysis of candlestick patterns, amplitude, and volume. While certain risks exist, the strategy’s stability and reliability can be further enhanced through the suggested optimization directions. The core advantages lie in its multi-dimensional analysis method and comprehensive state management mechanism, making it suitable for application in highly volatile market environments.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-10 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Candle Absorption Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100) // Условия индикатора // 1. Две соседних свечи должны быть разнонаправленными condition1 = (close[1] > open[1] and close < open) or (close[1] < open[1] and close > open) // 2. Дельта по цене открытия/закрытия у первой свечи меньше, чем у следующей delta1 = math.abs(close[1] - open[1]) delta2 = math.abs(close - open) condition2 = delta1 < delta2 // 3. Объем первой свечи должен быть больше, а последней меньше condition3 = volume[1] > volume and volume < volume[2] // Проверяем выполнение всех условий all_conditions = condition1 and condition2 and condition3 // Определяем направление для входа is_bullish = close > open // Зеленая свеча больше (бычье поглощение) is_bearish = close < open // Красная свеча больше (медвежье поглощение) // Переменные для отслеживания состояния позиции var float entryPrice = na var bool isLong = false var bool isShort = false // Логика генерации сигналов buySignal = all_conditions and is_bullish and not isLong sellSignal = all_conditions and is_bearish and not isShort // Обработка лонгового входа if (buySignal) isLong := true isShort := false entryPrice := close strategy.entry("Long", strategy.long) // Обработка шортового входа if (sellSignal) isLong := false isShort := true entryPrice := close strategy.entry("Short", strategy.short) // Визуализация точек поглощения // if all_conditions // label.new(bar_index, high, "✔", color=is_bullish ? color.green : color.red, textcolor=color.white, style=label.style_circle, size=size.small) // Логика сброса состояния при закрытии позиции if (strategy.position_size == 0) isLong := false isShort := false entryPrice := na // Дополнительно: можно добавить стоп-лосс и тейк-профит (пример ниже) // strategy.exit("Exit Long", from_entry="Long", stop=low - atr(14), limit=high + atr(14)) // strategy.exit("Exit Short", from_entry="Short", stop=high + atr(14), limit=low - atr(14))