0bps

Strategy vault / Breakout

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…

Author
ChaoZhang
Complexity
Starter · 49 lines
Parameters
0
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

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:

  1. Uses 14-period EMA as the main trend reference line
  2. Requires current closing price to break above EMA, forming an upward crossover
  3. Confirms current candle is bullish (close higher than open)
  4. Requires at least 50% of the candle body to be above the EMA
  5. 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

  1. Comprehensive signal confirmation: Combines EMA crossover and candlestick pattern analysis to significantly improve signal reliability
  2. Reasonable risk control: Limits wick length ratio to avoid excessive market volatility
  3. Flexible parameter settings: Both 14-period EMA and 50% body penetration rate can be adjusted for different market characteristics
  4. Clear execution standards: Each condition has specific mathematical definitions for quantitative implementation
  5. Clear visual feedback: Traders can intuitively see buy signals through chart markings

Strategy Risks

  1. Trend continuation risk: EMA crossover signals may appear at trend endings, leading to false breakouts
  2. Market volatility risk: Signals may fail even when all conditions are met in highly volatile markets
  3. Parameter sensitivity risk: EMA period and candlestick conditions settings significantly impact strategy performance
  4. Lag risk: EMA has inherent lag, potentially missing optimal entry points
  5. Market environment dependency: Strategy performance varies significantly across different market conditions

Strategy Optimization Directions

  1. Incorporate volume indicators: Enhance signal reliability through volume confirmation
  2. Add trend strength filtering: Combine with other trend indicators like ADX to filter for stronger trends
  3. Optimize stop-loss settings: Implement dynamic stop-loss based on ATR or key support levels
  4. Improve exit mechanism: Design exit conditions corresponding to entry logic
  5. 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.

in Claude Code, Cursor, Codex & 4 more
/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
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open