Dynamic Buy Entry Strategy Combining EMA Crossing and Candle Body Penetration
This strategy is a buying system that combines the 14-period Exponential Moving Average (EMA) with candlestick technical analysis. It determines market entry points by observing the price-EMA crossover relationship…

Overview
This strategy is a buying system that combines the 14-period Exponential Moving Average (EMA) with candlestick technical analysis. It determines market entry points by observing the price-EMA crossover relationship along with candlestick pattern characteristics. This approach incorporates both trend factors and price structure analysis, forming a comprehensive trading system.
Strategy Principle
The core logic is based on the combination of several key conditions:
- Uses 14-period EMA as the main trend reference line
- Requires current closing price to break above EMA, forming an upward crossover
- Confirms current candle is bullish (close higher than open)
- Requires at least 50% of the candle body to be above the EMA
- Total wick length must not exceed 40% of the total candle length A buy signal is generated when all these conditions are met simultaneously. This multi-filter mechanism effectively reduces false signals.
Strategy Advantages
- Comprehensive signal confirmation: Combines EMA crossover and candlestick pattern analysis to significantly improve signal reliability
- Reasonable risk control: Limits wick length ratio to avoid excessive market volatility
- Flexible parameter settings: Both 14-period EMA and 50% body penetration rate can be adjusted for different market characteristics
- Clear execution standards: Each condition has specific mathematical definitions for quantitative implementation
- Clear visual feedback: Traders can intuitively see buy signals through chart markings
Strategy Risks
- Trend continuation risk: EMA crossover signals may appear at trend endings, leading to false breakouts
- Market volatility risk: Signals may fail even when all conditions are met in highly volatile markets
- Parameter sensitivity risk: EMA period and candlestick conditions settings significantly impact strategy performance
- Lag risk: EMA has inherent lag, potentially missing optimal entry points
- Market environment dependency: Strategy performance varies significantly across different market conditions
Strategy Optimization Directions
- Incorporate volume indicators: Enhance signal reliability through volume confirmation
- Add trend strength filtering: Combine with other trend indicators like ADX to filter for stronger trends
- Optimize stop-loss settings: Implement dynamic stop-loss based on ATR or key support levels
- Improve exit mechanism: Design exit conditions corresponding to entry logic
- Add market cycle analysis: Adjust strategy parameters based on different market cycles
Summary
This is a buying strategy that integrates multiple dimensions of technical analysis, building a relatively complete trading system through the combination of EMA trend following and candlestick pattern analysis. The strategy's main advantages lie in its signal confirmation mechanism reliability and reasonable risk control. While there are some inherent risks, the strategy's stability and reliability can be further enhanced through the suggested optimization directions.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Buy Entry with EMA Crossing and Wick Conditions", overlay=true)
// Define the EMA length
ema_length = input.int(14, title="EMA Length")
// Calculate the 14 EMA
ema_14 = ta.ema(close, ema_length)
// Calculate the candle body and wicks
body = close - open
upper_wick = high - close
lower_wick = open - low
total_candle_length = high - low
// Define the condition for the candle to be green (bullish)
is_green_candle = close > open
// Condition for crossing the 14 EMA (previous close was below, current close is above)
crossing_ema = ta.crossover(close, ema_14)
// Condition for at least 50% of the candle's body crossing the 14 EMA
body_crossed_ema = (close - open) * 0.5 <= (close - ema_14) and close > ema_14
// Condition for wick percent being less than or equal to 40% of the total candle length
wick_percent = (upper_wick + lower_wick) / total_candle_length
valid_wick_condition = wick_percent <= 0.4
// Define the buy condition
buy_condition = is_green_candle and crossing_ema and body_crossed_ema and valid_wick_condition
// Plot the 14 EMA on the chart
plot(ema_14, color=color.blue, linewidth=2, title="14 EMA")
// Plot the buy signal as an arrow on the chart
plotshape(buy_condition, color=color.green, style=shape.labelup, location=location.belowbar, text="BUY")
// Optional: Add a strategy for backtesting
if (buy_condition)
strategy.entry("Buy", strategy.long)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-20. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Dynamic-Buy-Entry-Strategy-Combining-EMA-Crossing-and-Candle-Body-Penetration.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Multi Filter Trend Breakthrough Smart Moving Average Trading StrategyPine Script · Breakout · 1h
- Multi Technical Indicator Dynamic Wave Trading StrategyPine Script · Breakout · 1h
- Multi Technical Indicator Trend Following Channel Breakout Trading Strategy with Candlestick Pattern Filtering SystemPine Script · Breakout · 1h
- Pivot Based Volume Weighted Breakout Reversal StrategyPine Script · Breakout · 1d
- Multi Strategy Adaptive Trend Following and Breakout Trading SystemPine Script · Breakout · 1d
- Multi Trend Breakout Momentum Trading StrategyPine Script · Breakout · 1d