1. Introduction & Hook
In the world of algorithmic trading, strategies that blend simplicity with effectiveness are highly sought after. The Kicking (Bullish/Bearish) strategy stands out as a robust candlestick-based approach, offering traders a clear framework for identifying market reversals and momentum shifts. Whether you are a seasoned Pine Script developer or a trader seeking to automate your edge, mastering the Kicking strategy can elevate your trading performance. This article provides a comprehensive, step-by-step guide to understanding, implementing, and optimizing the Kicking strategy across multiple platforms and programming languages. Dive deep into the logic, mathematics, code, and practical nuances that make this strategy a staple in the toolkit of professional traders.
2. What is Kicking (Bullish/Bearish)?
The Kicking strategy is a candlestick pattern-based trading approach that identifies strong bullish or bearish reversals. It is characterized by two consecutive Marubozu candles of opposite colors, separated by a gap. The first candle is a Marubozu (a candle with little or no wicks), followed by a gap in the opposite direction, and then another Marubozu of the opposite color. This pattern signals a dramatic shift in market sentiment, often leading to significant price moves.
- Bullish Kicking: A bearish Marubozu followed by a bullish Marubozu, with a gap up between them.
- Bearish Kicking: A bullish Marubozu followed by a bearish Marubozu, with a gap down between them.
The Kicking pattern is rare but powerful, providing high-probability signals for trend reversals or strong continuations.
3. Market Logic Behind the Strategy
The Kicking strategy is rooted in the psychology of market participants. The first Marubozu candle represents overwhelming control by one side (bulls or bears), pushing the price decisively in one direction. The subsequent gap and opposite Marubozu indicate a sudden and forceful shift in sentiment, often triggered by news, earnings, or macroeconomic events. This abrupt reversal catches many traders off guard, leading to rapid price adjustments as positions are unwound and new trends are established.
- For Bulls: The gap up and strong bullish candle suggest that buyers have seized control, overwhelming previous selling pressure.
- For Bears: The gap down and strong bearish candle indicate that sellers have taken charge, reversing prior bullish momentum.
Understanding this logic helps traders anticipate the potential for explosive moves following a Kicking pattern, making it a valuable tool for both discretionary and systematic trading.
4. Mathematical Foundation & Formula
The Kicking strategy relies on precise identification of Marubozu candles and gaps. The mathematical criteria are as follows:
- Marubozu Candle: A candle with a very small or nonexistent upper and lower wick. Typically, the wick size is less than a specified percentage (e.g., 5%) of the total candle range.
- Gap: The open of the second candle is above (bullish) or below (bearish) the close of the first candle, with no overlap.
Bullish Kicking Formula:
- First candle: Bearish Marubozu (close < open, small wicks)
- Second candle: Bullish Marubozu (close > open, small wicks)
- Gap up: Second open > first close
Bearish Kicking Formula:
- First candle: Bullish Marubozu (close > open, small wicks)
- Second candle: Bearish Marubozu (close < open, small wicks)
- Gap down: Second open < first close
5. Step-by-Step Calculation Example
Letβs walk through a bullish Kicking pattern example:
- Candle 1 (Bearish Marubozu):
- Open: 100
- High: 101
- Low: 99
- Close: 99.1
- Upper wick: 101 - 100 = 1
- Lower wick: 99.1 - 99 = 0.1
- Body: 100 - 99.1 = 0.9
- Wick/body ratio: (1 + 0.1) / 0.9 β 1.22 (if threshold is 5%, this is not a perfect Marubozu, but for illustration, assume small wicks)
- Candle 2 (Bullish Marubozu):
- Open: 100.5 (gap up from 99.1)
- High: 102
- Low: 100.5
- Close: 101.9
- Upper wick: 102 - 101.9 = 0.1
- Lower wick: 100.5 - 100.5 = 0
- Body: 101.9 - 100.5 = 1.4
- Wick/body ratio: 0.1 / 1.4 β 0.07
- Gap: 100.5 (second open) > 99.1 (first close)
This sequence meets the criteria for a bullish Kicking pattern.
6. Pine Script Implementation
Below is a robust Pine Script implementation of the Kicking (Bullish/Bearish) strategy. This script detects both bullish and bearish patterns and plots signals on the chart.
//@version=6
strategy("Kicking (Bullish/Bearish) Strategy", overlay=true)
// Parameters
marubozu_wick_pct = input.float(0.05, title="Max Wick % for Marubozu", minval=0.0, maxval=0.2)
// Helper function to check Marubozu
is_marubozu(open, high, low, close, wick_pct) =>
body = math.abs(close - open)
upper_wick = high - math.max(open, close)
lower_wick = math.min(open, close) - low
total_range = high - low
upper_wick <= total_range * wick_pct and lower_wick <= total_range * wick_pct
// Detect Bullish Kicking
bull_kick = is_marubozu(open[1], high[1], low[1], close[1], marubozu_wick_pct) and close[1] < open[1] and
is_marubozu(open, high, low, close, marubozu_wick_pct) and close > open and
open > close[1]
// Detect Bearish Kicking
bear_kick = is_marubozu(open[1], high[1], low[1], close[1], marubozu_wick_pct) and close[1] > open[1] and
is_marubozu(open, high, low, close, marubozu_wick_pct) and close < open and
open < close[1]
plotshape(bull_kick, title="Bullish Kicking", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(bear_kick, title="Bearish Kicking", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
if bull_kick
strategy.entry("BullKick", strategy.long)
if bear_kick
strategy.entry("BearKick", strategy.short)
This script is fully customizable and can be extended with risk management and filtering logic.
7. Parameters & Customization in Pine Script
Key parameters for tuning the Kicking strategy in Pine Script include:
- marubozu_wick_pct: Controls the strictness of Marubozu detection. Lower values require smaller wicks.
- Gap size: You may require a minimum gap size (e.g., 0.5% of price) for higher signal quality.
- Trade filters: Add volume, volatility, or trend filters to reduce false signals.
- Risk management: Integrate stop-loss, take-profit, and position sizing directly into the script.
Example of adding a minimum gap filter:
// Minimum gap filter
min_gap_pct = input.float(0.005, title="Min Gap %", minval=0.0, maxval=0.05)
gap_ok = math.abs(open - close[1]) >= close[1] * min_gap_pct
bull_kick := bull_kick and gap_ok
bear_kick := bear_kick and gap_ok
8. Python & FastAPI + NoSQL Implementation
For algorithmic traders and quants, implementing the Kicking strategy in Python enables backtesting, automation, and integration with modern data pipelines. Below is a Python example using Pandas, with a FastAPI endpoint for real-time signal generation, and a NoSQL (MongoDB) storage pattern.
import pandas as pd
from fastapi import FastAPI, Request
from pydantic import BaseModel
from pymongo import MongoClient
app = FastAPI()
client = MongoClient('mongodb://localhost:27017/')
db = client['trading']
collection = db['kicking_signals']
class Candle(BaseModel):
open: float
high: float
low: float
close: float
def is_marubozu(row, wick_pct=0.05):
body = abs(row['close'] - row['open'])
upper_wick = row['high'] - max(row['open'], row['close'])
lower_wick = min(row['open'], row['close']) - row['low']
total_range = row['high'] - row['low']
return upper_wick <= total_range * wick_pct and lower_wick <= total_range * wick_pct
def detect_kicking(df, wick_pct=0.05):
signals = []
for i in range(1, len(df)):
prev = df.iloc[i-1]
curr = df.iloc[i]
if is_marubozu(prev, wick_pct) and is_marubozu(curr, wick_pct):
# Bullish
if prev['close'] < prev['open'] and curr['close'] > curr['open'] and curr['open'] > prev['close']:
signals.append({'index': i, 'type': 'bullish'})
# Bearish
elif prev['close'] > prev['open'] and curr['close'] < curr['open'] and curr['open'] < prev['close']:
signals.append({'index': i, 'type': 'bearish'})
return signals
@app.post("/kicking_signal/")
async def kicking_signal(candles: list[Candle]):
df = pd.DataFrame([c.dict() for c in candles])
signals = detect_kicking(df)
# Store signals in MongoDB
if signals:
collection.insert_many(signals)
return {"signals": signals}
This API receives candle data, detects Kicking patterns, and stores signals in MongoDB for further analysis or execution.
9. Node.js / JavaScript Implementation
JavaScript is widely used for browser-based trading tools and Node.js backends. Hereβs a Node.js implementation for detecting Kicking patterns in OHLCV arrays:
// Kicking pattern detection in Node.js
function isMarubozu(candle, wickPct = 0.05) {
const body = Math.abs(candle.close - candle.open);
const upperWick = candle.high - Math.max(candle.open, candle.close);
const lowerWick = Math.min(candle.open, candle.close) - candle.low;
const totalRange = candle.high - candle.low;
return upperWick <= totalRange * wickPct && lowerWick <= totalRange * wickPct;
}
function detectKicking(candles, wickPct = 0.05) {
const signals = [];
for (let i = 1; i < candles.length; i++) {
const prev = candles[i - 1];
const curr = candles[i];
if (isMarubozu(prev, wickPct) && isMarubozu(curr, wickPct)) {
// Bullish
if (prev.close < prev.open && curr.close > curr.open && curr.open > prev.close) {
signals.push({ index: i, type: 'bullish' });
}
// Bearish
else if (prev.close > prev.open && curr.close < curr.open && curr.open < prev.close) {
signals.push({ index: i, type: 'bearish' });
}
}
}
return signals;
}
This function can be integrated into trading bots, browser extensions, or serverless functions for real-time signal generation.
10. Backtesting & Performance Insights
Backtesting is essential for validating the effectiveness of the Kicking strategy. In Pine Script, use the strategy framework to simulate trades and analyze metrics such as win rate, profit factor, and drawdown. In Python, leverage libraries like backtrader or zipline for historical simulations.
- Key metrics to evaluate:
- Number of trades
- Win/loss ratio
- Average profit/loss per trade
- Maximum drawdown
- Sharpe ratio
Example: In Pine Script, the strategy.performance tab provides detailed analytics. In Python, use bt.analyze() or custom Pandas analysis for performance breakdowns.
11. Risk Management Integration
Effective risk management is crucial for long-term trading success. Integrate position sizing, stop-loss, and take-profit logic directly into your Kicking strategy scripts.
- Position sizing: Calculate trade size based on account equity and risk per trade.
- Stop-loss: Place stops below (bullish) or above (bearish) the signal candle.
- Take-profit: Set profit targets based on ATR, fixed ratio, or trailing logic.
Example Pine Script with automated exits:
// Risk management parameters
risk_pct = input.float(1, title="Risk % per Trade", minval=0.1, maxval=5)
stop_loss_atr = input.float(1.5, title="Stop Loss ATR Multiplier")
take_profit_atr = input.float(3.0, title="Take Profit ATR Multiplier")
atr = ta.atr(14)
if bull_kick
stop = low - stop_loss_atr * atr
target = close + take_profit_atr * atr
strategy.entry("BullKick", strategy.long)
strategy.exit("TP/SL", from_entry="BullKick", stop=stop, limit=target)
if bear_kick
stop = high + stop_loss_atr * atr
target = close - take_profit_atr * atr
strategy.entry("BearKick", strategy.short)
strategy.exit("TP/SL", from_entry="BearKick", stop=stop, limit=target)
This approach ensures disciplined exits and consistent risk exposure.
12. Combining with Other Indicators
Enhance the reliability of Kicking signals by combining them with trend, momentum, or volume indicators. Common combinations include:
- Moving Averages: Filter signals to trade only in the direction of the prevailing trend.
- RSI/Stochastic: Confirm overbought/oversold conditions before acting on Kicking patterns.
- Volume: Require above-average volume for higher conviction signals.
Example Pine Script filter:
// Only trade bullish Kicking if above 200 EMA
ema200 = ta.ema(close, 200)
bull_kick := bull_kick and close > ema200
13. Multi-Timeframe & Multi-Asset Usage
The Kicking strategy is versatile and can be applied across different timeframes and asset classes:
- Timeframes: 1-minute, 15-minute, daily, weekly. Shorter timeframes yield more signals but may be noisier.
- Assets: Equities, forex, crypto, commodities, options. Adjust parameters for volatility and liquidity.
Example: In Pine Script, use request.security() to fetch higher timeframe data for confirmation.
// Confirm with daily Kicking pattern on intraday chart
bull_kick_daily = request.security(syminfo.tickerid, "D", bull_kick)
bull_kick := bull_kick and bull_kick_daily
14. AI/ML Enhancements
Machine learning can optimize Kicking strategy parameters and signal quality. Feature engineering may include:
- Gap size
- Marubozu strictness
- Volume spike
- Trend context
Example: Reinforcement learning (RL) agent tuning parameters for maximum Sharpe ratio.
# Pseudocode for RL agent optimizing Kicking parameters
for episode in range(num_episodes):
params = agent.sample_parameters()
rewards = backtest_kicking(params)
agent.update_policy(rewards)
Integrate with Python libraries like stable-baselines3 or Ray RLlib for advanced optimization.
15. Automation with Playwright/Jest
Automated testing ensures your Kicking strategy scripts remain robust as code evolves. Use playwright for end-to-end browser tests or Jest for unit testing in Node.js.
// Jest unit test for Kicking detection
const { detectKicking } = require('./kicking');
test('detects bullish kicking', () => {
const candles = [
{ open: 100, high: 101, low: 99, close: 99.1 },
{ open: 100.5, high: 102, low: 100.5, close: 101.9 }
];
const signals = detectKicking(candles);
expect(signals[0].type).toBe('bullish');
});
Playwright can automate TradingView UI to verify script signals visually.
16. Advanced Variations
Advanced traders may adapt the Kicking strategy by:
- Requiring confirmation from multiple timeframes
- Combining with volatility breakouts
- Using adaptive thresholds for Marubozu detection
- Integrating with order flow or sentiment data
These variations can improve robustness and adapt the strategy to changing market regimes.
17. Common Pitfalls & Misconceptions
- Overfitting: Excessive parameter tuning on historical data may not generalize to live markets.
- Ignoring volume: Low-volume Kicking patterns are less reliable.
- Chasing every signal: Not all Kicking patterns lead to strong moves; use filters and context.
- Neglecting slippage and commissions: Backtests without realistic costs may overstate performance.
18. Conclusion & Key Takeaways
The Kicking (Bullish/Bearish) strategy is a powerful, pattern-based approach for capturing sharp market reversals. By understanding its logic, mathematical foundation, and implementation nuances, traders can harness its potential across asset classes and timeframes. Integrate robust risk management, combine with other indicators, and leverage automation and AI to maximize your edge. Always backtest thoroughly and adapt to evolving market conditions for sustained success.
Glossary of Key Terms
- Marubozu: A candlestick with little or no wicks, indicating strong directional momentum.
- Gap: A price difference between the close of one candle and the open of the next, with no overlap.
- Bullish/Bearish: Indicating upward or downward price movement, respectively.
- Backtesting: Simulating a strategy on historical data to evaluate performance.
- ATR (Average True Range): A volatility indicator used for setting stops and targets.
- Risk Management: Techniques to control losses and manage trade size.
- Reinforcement Learning: A machine learning paradigm for optimizing strategies via trial and error.
Comparison Table
| Strategy | Signal Type | Complexity | Reliability | Best Use Case |
|---|---|---|---|---|
| Kicking | Reversal | Medium | High (rare, strong) | Major trend shifts |
| Engulfing | Reversal | Low | Medium | Frequent, less explosive |
| Morning/Evening Star | Reversal | Medium | Medium-High | Trend reversals |
| Doji | Indecision | Low | Low | Trend pauses |
| Hammer/Shooting Star | Reversal | Low | Medium | Short-term reversals |
TheWallStreetBulls