Logo

dev-resources.site

for different kinds of informations.

Dynamic ATR Trend Following Strategy Based on Support Level Breakthrough

Published at
1/10/2025
Categories
cryptocurrency
trading
strategy
atr
Author
fmzquant
Author
8 person written this
fmzquant
open
Dynamic ATR Trend Following Strategy Based on Support Level Breakthrough

Image description

Overview
This is a dynamic ATR trend following strategy based on support level breakthrough. The strategy combines the EMA moving average system, ATR volatility indicator and Smart Money Concept (SMC) to capture market trends. The strategy achieves good risk management by dynamically calculating position size and stop loss and take profit positions.

Strategy Principle
The strategy is mainly built on the following core components:

  1. Use the 50 and 200 period EMA moving average system to confirm the market trend direction
  2. Use the ATR indicator to dynamically adjust stop loss and profit targets
  3. Find the best entry point through Order Block and Imbalance Zone analysis
  4. Automatically calculate opening volume based on account risk percentage
  5. By observing the fluctuation range of the past 20 K-lines, we can judge whether the market is in a consolidation state.

Strategy Advantages

  1. Perfect risk management, through dynamic calculation to ensure that the risk of each transaction is controllable
  2. The trend judgment system is reliable and avoids trading in a consolidation market
  3. The stop loss and take profit settings are reasonable, and the risk-return ratio is 1:3
  4. Fully consider market volatility and be able to adapt to different market environments
  5. The code structure is clear, easy to maintain and optimize

Strategy Risks

  1. The EMA indicator has a lag, which may cause a delay in entry
  2. False signals may be triggered in volatile markets
  3. The strategy relies on trend persistence and may perform poorly in volatile markets
  4. The stop loss position is wider, and in some cases, you may suffer a larger loss

Strategy Optimization Direction

  1. The volume-price relationship analysis can be introduced to improve the accuracy of trend judgment
  2. Can increase market sentiment indicators and optimize entry timing
  3. Consider adding multi-time period analysis to improve system stability
  4. The judgment criteria for order blocks and imbalance areas can be refined
  5. Optimize the stop loss method and consider using a moving stop loss

Summary
This strategy is a relatively complete trend tracking system, which improves the stability of trading through reasonable risk management and multiple signal confirmation. Although there is a certain lag, it is a reliable trading system overall. It is recommended to conduct sufficient backtesting verification before real-time use, and optimize parameters according to specific trading products and market environment.

Strategy source code

/*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"}]
*/

// TradingView Pine Script strategy for Smart Money Concept (SMC)
//@version=5
strategy("Smart Money Concept Strategy", overlay=true, default_qty_type=strategy.fixed, default_qty_value=100)

// === Input Parameters ===
input_risk_percentage = input.float(1, title="Risk Percentage", step=0.1)
input_atr_length = input.int(14, title="ATR Length")
input_ema_short = input.int(50, title="EMA Short")
input_ema_long = input.int(200, title="EMA Long")

// === Calculations ===
atr = ta.atr(input_atr_length)
ema_short = ta.ema(close, input_ema_short)
ema_long = ta.ema(close, input_ema_long)

// === Utility Functions ===
// Identify Order Blocks
is_order_block(price, direction) =>
    ((high[1] > high[2] and low[1] > low[2] and direction == 1) or (high[1] < high[2] and low[1] < low[2] and direction == -1))

// Identify Imbalance Zones
is_imbalance() =>
    range_high = high[1]
    range_low = low[1]
    range_high > close and range_low < close

// Calculate Lot Size Based on Risk
calculate_lot_size(stop_loss_points, account_balance) =>
    risk_amount = account_balance * (input_risk_percentage / 100)
    lot_size = risk_amount / (stop_loss_points * syminfo.pointvalue)
    lot_size

// Determine if Market is Consolidating
is_consolidating() =>
    (ta.highest(high, 20) - ta.lowest(low, 20)) / atr < 2

// === Visual Enhancements ===
// Plot Order Blocks
// if is_order_block(close, 1)
//     line.new(x1=bar_index[1], y1=low[1], x2=bar_index, y2=low[1], color=color.green, width=2, extend=extend.right)
// if is_order_block(close, -1)
//     line.new(x1=bar_index[1], y1=high[1], x2=bar_index, y2=high[1], color=color.red, width=2, extend=extend.right)

// Highlight Imbalance Zones
// if is_imbalance()
//     box.new(left=bar_index[1], top=high[1], right=bar_index, bottom=low[1], bgcolor=color.new(color.orange, 80))

// === Logic for Trend Confirmation ===
is_bullish_trend = ema_short > ema_long
is_bearish_trend = ema_short < ema_long

// === Entry Logic ===
account_balance = strategy.equity
if not is_consolidating()
    if is_bullish_trend
        stop_loss = close - atr * 2
        take_profit = close + (math.abs(close - (close - atr * 2)) * 3)
        stop_loss_points = math.abs(close - stop_loss) / syminfo.pointvalue
        lot_size = calculate_lot_size(stop_loss_points, account_balance)
        strategy.entry("Buy", strategy.long, qty=lot_size)
        strategy.exit("TP/SL", "Buy", stop=stop_loss, limit=take_profit)

    if is_bearish_trend
        stop_loss = close + atr * 2
        take_profit = close - (math.abs(close - (close + atr * 2)) * 3)
        stop_loss_points = math.abs(close - stop_loss) / syminfo.pointvalue
        lot_size = calculate_lot_size(stop_loss_points, account_balance)
        strategy.entry("Sell", strategy.short, qty=lot_size)
        strategy.exit("TP/SL", "Sell", stop=stop_loss, limit=take_profit)

// === Plotting Indicators ===
plot(ema_short, color=color.blue, title="EMA 50")
plot(ema_long, color=color.orange, title="EMA 200")
plotshape(series=is_bullish_trend and not is_consolidating(), style=shape.triangleup, location=location.belowbar, color=color.green, text="Buy")
plotshape(series=is_bearish_trend and not is_consolidating(), style=shape.triangledown, location=location.abovebar, color=color.red, text="Sell")
Enter fullscreen mode Exit fullscreen mode

Strategy parameters

Image description

The original address: https://www.fmz.com/strategy/474884

trading Article's
30 articles in total
Favicon
EMA-MACD Composite Strategy for Trend Scalping
Favicon
Dynamic Timing and Position Management Strategy Based on Volatility
Favicon
Multi-Market Adaptive Multi-Indicator Trend Following Strategy
Favicon
Multi-EMA Trend Following Strategy with SMMA Confirmation
Favicon
Multi-Indicator Trend Following Strategy with Bollinger Bands and ATR Dynamic Stop Loss
Favicon
Dynamic Pivot Points with Crossup Optimization System
Favicon
Multi-Timeframe Trend Dynamic ATR Tracking Strategy
Favicon
Multi-dimensional Gold Friday Anomaly Strategy Analysis System
Favicon
Mean Reversion Bollinger Band Dollar-Cost Averaging Investment Strategy
Favicon
Dynamic ATR Trend Following Strategy Based on Support Level Breakthrough
Favicon
Price Pattern Based Double Bottom and Top Automated Trading Strategy
Favicon
Multi-Indicator Adaptive Trading Strategy Based on RSI, MACD and Volume
Favicon
Multi-Moving Average Trend Following Strategy - Long-term Investment Signal System Based on EMA and SMA Indicators
Favicon
Dual EMA Crossover Strategy with Smart Risk-Reward Control
Favicon
Multi-Period EMA Crossover with RSI Momentum and ATR Volatility Based Trend Following Strategy
Favicon
Dual EMA Stochastic Trend Following Trading Strategy
Favicon
Multi-Wave Trend Crossing Risk Management Quantitative Strategy
Favicon
Dynamic EMA Trend Crossover Entry Quantitative Strategy
Favicon
Enhanced Mean Reversion Strategy with MACD-ATR Implementation
Favicon
Bollinger Bands Momentum Breakout Adaptive Trend Following Strategy
Favicon
Multi-Indicator Synergistic Trend Following Strategy with Dynamic Stop-Loss System
Favicon
Adaptive Range Trading System Based on Dual RSI Indicators
Favicon
Advanced Five-Day Cross-Analysis Strategy Based on RSI and MACD Integration
Favicon
Advanced Quantitative Trend Capture Strategy with Dynamic Range Filter
Favicon
Multi-Technical Indicator Trend Following Strategy with RSI Momentum Filter
Favicon
Advanced Trend Following Strategy with Adaptive Trailing Stop
Favicon
Multi-Timeframe Trend Following Strategy with ATR-Based Take Profit and Stop Loss
Favicon
Triple Supertrend and Bollinger Bands Multi-Indicator Trend Following Strategy
Favicon
Dual Moving Average Trend Following Strategy with Risk Management
Favicon
Quantitative Long-Short Switching Strategy Based on G-Channel and EMA

Featured ones: