고급 거래 패턴 인식 및 역동적인 위험 관리 전략

EMA ATR FIBONACCI ENGULFING volatility VOLUME RISK-REWARD
생성 날짜: 2025-06-19 13:57:50 마지막으로 수정됨: 2025-06-19 13:57:50
복사: 4 클릭수: 287
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

고급 거래 패턴 인식 및 역동적인 위험 관리 전략 고급 거래 패턴 인식 및 역동적인 위험 관리 전략

전략 개요

고급 거래 패턴 식별 및 동적 위험 관리 전략은 정밀한 흡수 형태 식별 기술과 동적 위험 관리 시스템을 결합한 양적 거래 전략이다. 이 전략의 핵심은 고급 수학 검증 방법을 통해 시장의 흡수 형태를 정확하게 식별하고, 50주기 지수 이동 평균 ((EMA) 을 트렌드 필터로 결합하여 거래 방향이 지배적 인 시장 추세와 일치하는지 확인한다. 이 전략은 깊이 있는 분석을 통해 그래프 형태, 거래량 확인 및 변동성 필터링과 같은 다중 기술 지표를어 높은 확률의 거래 신호를 가하며, 피파노 보노치치치 수준의 동적 중지 손실 및 수익 목표를 기반으로 지능적인 위험 관리를 구현한다.

전략 원칙

이 전략은 다음과 같은 몇 가지 핵심 요소의 협동에 기반을 두고 있습니다.

  1. 트렌드 인식 시스템50주기 EMA를 주요 트렌드 지표로 사용한다. EMA 위쪽에 있는 가격은 상승 트렌드로 인식되어 더하기 적합하다. EMA 아래쪽에 있는 가격은 하향 트렌드로 인식되어 더하기 적합하다. 이것은 거래가 항상 시장의 지배적인 방향을 따르도록 보장한다.

  2. 고급 삼킨 형태 인식: 전략은 강화된 버전의 포식 형태를 탐지하고, 현재 이 전 을 완전히 “포식”하도록 요구하며, 수학적인 검증을 통해 의 질을 보장한다. 시스템은 분석한다:

    • 현재 유체와 이전 유체의 비율 ((최소한 삼키기 비율)
    • 위아래 그림선과 실체의 비율 (최대 그림선 비율)
    • 현재 의 전체 크기와 평균 실제 범위 ((ATR) 의 관계
  3. 다중 필터링 장치

    • 거래량 필터링: 거래량이 평균보다 특정 배수를 초과하는 것을 확인합니다.
    • 변동성 필터: ATR을 통해 시장 변동성이 적절한 거래 조건에 도달했음을 확인합니다.
    • 그림자 선 품질 제어: 상하 그림자 선 크기를 제한하여 신호 품질을 향상시킨다
  4. 동적 위험 관리

    • 손해 계산: 피보나치 레벨, 고정 금액 또는 ATR 배수를 기반으로 한 여러 손해 방지 전략을 지원합니다.
    • 수익 목표: 고정 리스크 수익률 또는 피보나치 레벨로 목표를 설정할 수 있습니다.
    • 거래 비용을 자동으로 계산하여 실제 거래 환경에서 전략의 실행성을 보장합니다.

전략적 이점

코드에 대한 심층적인 분석을 통해 이 전략은 다음과 같은 중요한 장점을 보여준다.

  1. 정확한 입학 시간트렌드, 형태 및 여러 확인 지표를 결합하여 전략은 시장에서 통계적으로 우위를 차지하는 고품질 입시점을 식별 할 수 있으며 단일 지표가 가져올 수있는 잘못된 신호를 피할 수 있습니다.

  2. 자율적 위험 관리고정된 파라미터의 전통적인 전략과는 달리, 이 전략의 위험 관리 시스템은 현재 시장 조건에 따라 동적으로 조정되며, 피보나치 레벨 또는 ATR 값을 사용하여 중지 손실과 수익 목표를 계산하여 다른 시장 환경에 더 잘 적응합니다.

  3. 전체적인 시각적 지원전략: 전략은 입문 신호, 정지/수익 수준, 현재 트렌드 상태 및 실시간 P&L 추적을 포함한 포괄적인 차트 표기 및 정보 패널을 제공하여 거래자가 시장 상태와 전략 성능을 직관적으로 이해할 수 있도록 도와줍니다.

  4. 고도의 사용자 정의전략은 EMA 길이, 흡수율, 리스크 수익률 등과 같은 풍부한 변수 설정을 제공하여 거래자가 개인 위험 선호도 및 다른 시장 조건에 따라 전략 성능을 조정할 수 있습니다.

  5. 통합 거래 비용 고려전략 내장 거래 수수료 계산은 많은 거래 시스템에서 종종 무시되는 중요한 요소이며, 실제 거래 환경에 더 가깝게 재검토 결과를 보장합니다.

전략적 위험

이 전략은 여러 장점에도 불구하고 다음과 같은 잠재적인 위험과 한계를 가지고 있습니다.

  1. 시장 환경 의존성전략은 트렌드가 명확한 시장에서 가장 잘 작동하며, 수평 정리 또는 높은 변동성이있는 방향없는 시장에서 더 많은 가짜 신호를 일으킬 수 있습니다. 해결책은 전략을 사용하기 전에 더 높은 시간 프레임의 시장 상태를 평가하거나 추가 시장 구조 필터를 추가하는 것입니다.

  2. 변수 최적화 함수과잉 최적화 파라미터는 커브 적합성을 초래할 수 있으며, 미래 시장 환경에서 좋지 않은 성능을 발휘할 수 있다. 파라미터의 유효성을 검증하기 위해 전향 테스트 또는 다른 시장 조건에서의 안정성 테스트를 사용하는 것이 좋습니다.

  3. 파격 위험을 막기극한 시장의 변동이나 유동성이 부족한 상황에서 실제 상쇄는 예상 손실을 초과하는 지각을 겪을 수 있습니다. 상쇄 보퍼 영역을 늘리거나 더 보수적인 포지션 규모를 사용하여 이러한 위험을 줄일 수 있습니다.

  4. 기술 지표의 뒤처짐EMA 및 다른 기술 지표는 본질적으로 지연성이 있으며, 시장이 급격하게 변할 때 반응이 부족할 수 있습니다. 더 높은 시간 프레임 분석과 결합하거나 조기 경고 지표를 추가하는 것이 부족함을 보완하는 것이 좋습니다.

  5. 거래량과 품질 문제: 전략은 거래량 구조와 품질을 고려하지 않고 거래량 크기를 고려합니다. 특정 시장 조건에서 오해 할 수 있습니다. 거래량 분산 분석이나 자금 흐름 지표의 심리를 추가하여 거래량 분석을 강화 할 수 있습니다.

전략 최적화 방향

코드 분석을 바탕으로, 이 전략은 다음과 같은 방향으로 최적화될 수 있습니다:

  1. 시장 상태는 적응합니다.

    • 시장 구조를 식별하는 기능을 구현하고, 트렌드 및 분기 시장에서 다른 매개 변수 세트를 사용합니다.
    • 시장의 변동성 지수 (VIX) 또는 다른 시장 정서 지표를 도입하여 높은 변동성 동안 자동으로 위험 매개 변수를 조정합니다.
    • 이유: 전략이 다양한 시장 환경에 현명하게 적응할 수 있게 하고, 전체적으로 안정성을 높일 수 있게 해준다.
  2. 다중 시간 프레임 분석

    • 더 높은 시간 프레임의 트렌드 확인 메커니즘에 가입하십시오.
    • 낮은 시간 프레임으로 최적화된 출전 정확도
    • 이유: 다중 시간 프레임 분석은 트렌드 식별의 정확성을 크게 향상시키고 역동 거래를 줄일 수 있습니다.
  3. 고급 거래량 분석

    • 거래량 가중 이동 평균 ((VWMA) 을 추가로 트렌드 확인으로 도입
    • 전체 거래량보다 매매 압박을 분석하는 방법
    • 이유: 더 정교한 거래량 분석은 시장 참여자의 행동에 대한 더 깊은 통찰력을 제공합니다.
  4. 기계 학습 강화

    • 간단한 기계 학습 알고리즘을 사용하여 자동으로 최적화 변수
    • 역사적인 데이터에 기반하여 가장 좋은 삼킨 형태 특징
    • 이유는: 기계학습은 인간에게 발견하기 어려운 미묘한 패턴과 연관성을 식별할 수 있습니다.
  5. 위험 관리 강화

    • 계정 순액에 기반한 동적 포지션 규모 조정
    • 날짜/주/월 위험 제한을 추가합니다.
    • 이윤 손실 균형 (break-even) 기능을 도입
    • 왜: 더 나은 리스크 관리가 장기적인 거래 성공의 기반입니다.

요약하다

고급 거래 패턴 식별 및 동적 위험 관리 전략은 전통적인 포식 형태 분석 기술과 현대적인 양적 방법을 결합하여 포괄적인 거래 프레임 워크를 만드는 정교하게 설계된 거래 시스템입니다. 이 전략의 핵심 장점은 다차원적인 신호 확인 메커니즘과 적응력있는 위험 관리 시스템으로 다양한 시장 조건에서 비교적 안정적인 성능을 유지할 수 있습니다.

이 전략은 50 EMA 트렌드 필터링, 고급 포식 형태 인식, 거래량 및 변동성 확인과 같은 여러 메커니즘을 통해 입문 신호의 품질을 크게 향상시킵니다. 또한 피보나치 레벨 또는 ATR 배수를 계산한 동적 중단 및 수익 목표를 통해 각 거래에 대한 명확한 리스크 수익 구조를 제공합니다.

시장 환경 의존성 및 기술 지표 지연과 같은 고유 한 한계에도 불구하고, 시장 상태의 자율 적응, 다중 시간 프레임 분석 및 기계 학습 강화와 같은 제안 된 최적화 방향을 통해이 전략은 안정성과 적응력을 더욱 향상시킬 잠재력을 가지고 있습니다.

전략 소스 코드
/*backtest
start: 2025-05-19 00:00:00
end: 2025-06-18 00:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("🎯 IKODO Engulfing Strategy with Dynamic RR & Commission", shorttitle="IKODO Engulfing Pro", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, pyramiding=0, calc_on_every_tick=false, calc_on_order_fills=false, commission_type=strategy.commission.percent, commission_value=0.04)

// ═══════════════════════════════════════════════════════════════════════════════
// 📊 ADVANCED INPUT PARAMETERS
// ═══════════════════════════════════════════════════════════════════════════════

// Commission Settings
enable_commission = input.bool(true, "Enable Commission", group="💰 Commission Settings")
commission_rate = input.float(0.04, "Commission Rate (%)", minval=0.0, maxval=1.0, step=0.01, group="💰 Commission Settings", tooltip="Binance Futures: 0.02% Maker, 0.04% Taker")
commission_type_input = input.string("Percentage", "Commission Type", options=["Percentage", "Fixed USD"], group="💰 Commission Settings")

// Risk Management Inputs
rr_ratio = input.float(2.0, "Risk Reward Ratio", minval=0.5, maxval=10.0, step=0.1, group="🎯 Risk Management")
use_fibonacci_tp = input.bool(true, "Use Fibonacci Levels for TP", group="🎯 Risk Management")
fib_level_tp = input.float(0.618, "Fibonacci Level for TP", minval=0.236, maxval=1.0, step=0.001, group="🎯 Risk Management")

// Stop Loss Settings
sl_type = input.string("Fibonacci", "Stop Loss Type", options=["Fibonacci", "Fixed USD", "ATR Multiple"], group="🛡️ Stop Loss Settings")
sl_fib_level = input.float(0.236, "Fibonacci Level for SL", minval=0.1, maxval=0.5, step=0.001, group="🛡️ Stop Loss Settings")
sl_fixed_usd = input.float(50.0, "Fixed Stop Loss (USD)", minval=1.0, maxval=1000.0, step=1.0, group="🛡️ Stop Loss Settings")
sl_atr_multiple = input.float(1.5, "ATR Multiple for SL", minval=0.5, maxval=5.0, step=0.1, group="🛡️ Stop Loss Settings")

// EMA Settings
ema_length = input.int(50, "EMA Length", minval=1, maxval=200, group="📈 Trend Filter")
ema_source = input.source(close, "EMA Source", group="📈 Trend Filter")

// Pattern Recognition Settings
min_engulf_ratio = input.float(0.1, "Minimum Engulfing Ratio", minval=0.01, maxval=1.0, step=0.01, group="🔍 Pattern Recognition")
max_wick_ratio = input.float(0.3, "Maximum Wick Ratio", minval=0.1, maxval=0.8, step=0.01, group="🔍 Pattern Recognition")

// Advanced Filters
volume_filter = input.bool(true, "Use Volume Filter", group="🔧 Advanced Filters")
volume_multiplier = input.float(1.2, "Volume Multiplier", minval=1.0, maxval=3.0, step=0.1, group="🔧 Advanced Filters")
atr_filter = input.bool(true, "Use ATR Volatility Filter", group="🔧 Advanced Filters")
atr_length = input.int(14, "ATR Length", minval=1, maxval=50, group="🔧 Advanced Filters")
min_atr_ratio = input.float(0.5, "Minimum ATR Ratio", minval=0.1, maxval=2.0, step=0.1, group="🔧 Advanced Filters")

// Visualization Settings
show_fibonacci_levels = input.bool(true, "Show Fibonacci Levels", group="🎨 Visualization")

// ═══════════════════════════════════════════════════════════════════════════════
// 🧮 QUANTITATIVE CALCULATIONS
// ═══════════════════════════════════════════════════════════════════════════════

// EMA Calculation
ema_50 = ta.ema(ema_source, ema_length)

// ATR for Volatility Assessment
atr = ta.atr(atr_length)

// Volume Analysis
avg_volume = ta.sma(volume, 20)
volume_condition = not volume_filter or volume > avg_volume * volume_multiplier

// Fibonacci calculation for swing levels
swing_high = ta.highest(high, 20)
swing_low = ta.lowest(low, 20)

// ═══════════════════════════════════════════════════════════════════════════════
// 🔍 ADVANCED PATTERN RECOGNITION
// ═══════════════════════════════════════════════════════════════════════════════

// Current and Previous Candle Properties
curr_body = math.abs(close - open)
prev_body = math.abs(close[1] - open[1])
curr_range = high - low
prev_range = high[1] - low[1]

// Candle Color Identification
curr_bullish = close > open
curr_bearish = close < open
prev_bullish = close[1] > open[1]
prev_bearish = close[1] < open[1]

// Enhanced Engulfing Pattern Detection
bullish_engulfing = curr_bullish and prev_bearish and close > high[1] and low < low[1] and curr_body > prev_body * min_engulf_ratio

bearish_engulfing = curr_bearish and prev_bullish and close < low[1] and high > high[1] and curr_body > prev_body * min_engulf_ratio

// Wick Analysis for Quality Filter
curr_upper_wick = curr_bullish ? high - close : high - open
curr_lower_wick = curr_bullish ? open - low : close - low
wick_filter_long = curr_upper_wick <= curr_range * max_wick_ratio
wick_filter_short = curr_lower_wick <= curr_range * max_wick_ratio

// ATR Volatility Filter
atr_filter_condition = not atr_filter or curr_range >= atr * min_atr_ratio

// ═══════════════════════════════════════════════════════════════════════════════
// 📈 TREND ANALYSIS & ENTRY CONDITIONS
// ═══════════════════════════════════════════════════════════════════════════════

// Trend Conditions
uptrend = close > ema_50
downtrend = close < ema_50

// Complete Entry Conditions
long_condition = uptrend and bullish_engulfing and wick_filter_long and volume_condition and atr_filter_condition

short_condition = downtrend and bearish_engulfing and wick_filter_short and volume_condition and atr_filter_condition

// ═══════════════════════════════════════════════════════════════════════════════
// 🎯 ADVANCED STOP LOSS CALCULATION
// ═══════════════════════════════════════════════════════════════════════════════

// Function to calculate stop loss based on type
calculate_stop_loss(entry_price, is_long, sl_type, swing_high, swing_low, atr, sl_fib_level, sl_fixed_usd, sl_atr_multiple) =>
    var float stop_loss = na
    
    if sl_type == "Fibonacci"
        if is_long
            fib_range = swing_high - swing_low
            stop_loss := swing_low + (fib_range * sl_fib_level)
        else
            fib_range = swing_high - swing_low
            stop_loss := swing_high - (fib_range * sl_fib_level)
    
    else if sl_type == "Fixed USD"
        if is_long
            stop_loss := entry_price - sl_fixed_usd
        else
            stop_loss := entry_price + sl_fixed_usd
    
    else if sl_type == "ATR Multiple"
        if is_long
            stop_loss := entry_price - (atr * sl_atr_multiple)
        else
            stop_loss := entry_price + (atr * sl_atr_multiple)
    
    stop_loss

// Function to calculate take profit
calculate_take_profit(entry_price, stop_loss, is_long, use_fibonacci_tp, swing_high, swing_low, fib_level_tp, rr_ratio) =>
    var float take_profit = na
    
    if use_fibonacci_tp
        if is_long
            fib_range = swing_high - swing_low
            take_profit := swing_low + (fib_range * fib_level_tp)
        else
            fib_range = swing_high - swing_low
            take_profit := swing_high - (fib_range * fib_level_tp)
    else
        // Traditional RR-based TP
        if is_long
            risk = entry_price - stop_loss
            take_profit := entry_price + (risk * rr_ratio)
        else
            risk = stop_loss - entry_price
            take_profit := entry_price - (risk * rr_ratio)
    
    take_profit

// ═══════════════════════════════════════════════════════════════════════════════
// 🎯 DYNAMIC RISK MANAGEMENT SYSTEM
// ═══════════════════════════════════════════════════════════════════════════════

// Dynamic Stop Loss and Take Profit Calculation
var float entry_price = na
var float stop_loss = na
var float take_profit = na
var float commission_cost = na

if long_condition and strategy.position_size == 0
    entry_price := close
    stop_loss := calculate_stop_loss(entry_price, true, sl_type, swing_high, swing_low, atr, sl_fib_level, sl_fixed_usd, sl_atr_multiple)
    take_profit := calculate_take_profit(entry_price, stop_loss, true, use_fibonacci_tp, swing_high, swing_low, fib_level_tp, rr_ratio)
    
    // Calculate commission cost
    commission_cost := enable_commission and commission_type_input == "Fixed USD" ? sl_fixed_usd * 2 : 0

if short_condition and strategy.position_size == 0
    entry_price := close
    stop_loss := calculate_stop_loss(entry_price, false, sl_type, swing_high, swing_low, atr, sl_fib_level, sl_fixed_usd, sl_atr_multiple)
    take_profit := calculate_take_profit(entry_price, stop_loss, false, use_fibonacci_tp, swing_high, swing_low, fib_level_tp, rr_ratio)
    
    // Calculate commission cost
    commission_cost := enable_commission and commission_type_input == "Fixed USD" ? sl_fixed_usd * 2 : 0

// ═══════════════════════════════════════════════════════════════════════════════
// 🚀 STRATEGY EXECUTION WITH COMMISSION
// ═══════════════════════════════════════════════════════════════════════════════

// Entry Orders
if long_condition
    strategy.entry("Long", strategy.long, comment="🟢 Elite Long Entry")

if short_condition
    strategy.entry("Short", strategy.short, comment="🔴 Elite Short Entry")

// Exit Orders
if strategy.position_size > 0
    strategy.exit("Long Exit", "Long", stop=stop_loss, limit=take_profit, comment="🎯 Long Exit")

if strategy.position_size < 0
    strategy.exit("Short Exit", "Short", stop=stop_loss, limit=take_profit, comment="🎯 Short Exit")

// ═══════════════════════════════════════════════════════════════════════════════
// 📊 ADVANCED VISUALIZATION - GLOBAL SCOPE
// ═══════════════════════════════════════════════════════════════════════════════

// EMA Plot
plot(ema_50, "EMA 50", color=color.new(color.blue, 0), linewidth=2)

// Entry Signals
plotshape(long_condition, "Long Signal", shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.normal)
plotshape(short_condition, "Short Signal", shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.normal)

// Support/Resistance Levels
plot(strategy.position_size != 0 ? stop_loss : na, "Stop Loss", color.new(color.red, 0), linewidth=2, style=plot.style_linebr)
plot(strategy.position_size != 0 ? take_profit : na, "Take Profit", color.new(color.green, 0), linewidth=2, style=plot.style_linebr)

// Entry Price Line
plot(strategy.position_size != 0 ? entry_price : na, "Entry Price", color.new(color.yellow, 0), linewidth=1, style=plot.style_linebr)

// Fibonacci Levels Visualization - MOVED TO GLOBAL SCOPE
show_fib_condition = show_fibonacci_levels and (sl_type == "Fibonacci" or use_fibonacci_tp)
plot(show_fib_condition ? swing_high : na, "Swing High", color.new(color.gray, 50), linewidth=1, style=plot.style_circles)
plot(show_fib_condition ? swing_low : na, "Swing Low", color.new(color.gray, 50), linewidth=1, style=plot.style_circles)

// Additional Fibonacci Levels
fib_range = swing_high - swing_low
fib_236 = swing_low + (fib_range * 0.236)
fib_382 = swing_low + (fib_range * 0.382)
fib_618 = swing_low + (fib_range * 0.618)
fib_786 = swing_low + (fib_range * 0.786)

plot(show_fib_condition ? fib_236 : na, "Fib 23.6%", color.new(color.orange, 70), linewidth=1, style=plot.style_linebr)
plot(show_fib_condition ? fib_382 : na, "Fib 38.2%", color.new(color.orange, 70), linewidth=1, style=plot.style_linebr)
plot(show_fib_condition ? fib_618 : na, "Fib 61.8%", color.new(color.orange, 70), linewidth=1, style=plot.style_linebr)
plot(show_fib_condition ? fib_786 : na, "Fib 78.6%", color.new(color.orange, 70), linewidth=1, style=plot.style_linebr)

// ═══════════════════════════════════════════════════════════════════════════════
// 📈 ENHANCED PERFORMANCE METRICS DISPLAY
// ═══════════════════════════════════════════════════════════════════════════════

// Enhanced Information Table
var table info_table = table.new(position.top_right, 3, 12, bgcolor=color.new(color.white, 85), border_width=1)

if barstate.islast
    table.cell(info_table, 0, 0, "📊 ELITE STRATEGY PRO", text_color=color.black, text_size=size.small)
    
    // Risk Management Info
    table.cell(info_table, 0, 1, "Risk-Reward Ratio:", text_color=color.black, text_size=size.tiny)
    table.cell(info_table, 1, 1, str.tostring(rr_ratio, "#.##"), text_color=color.blue, text_size=size.tiny)
    
    // Commission Info
    table.cell(info_table, 0, 2, "Commission:", text_color=color.black, text_size=size.tiny)
    commission_text = enable_commission ? (commission_type_input == "Percentage" ? str.tostring(commission_rate, "#.##") + "%" : "$" + str.tostring(sl_fixed_usd, "#.##")) : "Disabled"
    table.cell(info_table, 1, 2, commission_text, text_color=enable_commission ? color.red : color.gray, text_size=size.tiny)
    
    // Stop Loss Type
    table.cell(info_table, 0, 3, "Stop Loss Type:", text_color=color.black, text_size=size.tiny)
    table.cell(info_table, 1, 3, sl_type, text_color=color.purple, text_size=size.tiny)
    
    // EMA Period
    table.cell(info_table, 0, 4, "EMA Period:", text_color=color.black, text_size=size.tiny)
    table.cell(info_table, 1, 4, str.tostring(ema_length), text_color=color.blue, text_size=size.tiny)
    
    // Current Trend
    table.cell(info_table, 0, 5, "Current Trend:", text_color=color.black, text_size=size.tiny)
    trend_text = uptrend ? "🟢 BULLISH" : downtrend ? "🔴 BEARISH" : "⚪ NEUTRAL"
    trend_color = uptrend ? color.green : downtrend ? color.red : color.gray
    table.cell(info_table, 1, 5, trend_text, text_color=trend_color, text_size=size.tiny)
    
    // ATR
    table.cell(info_table, 0, 6, "ATR:", text_color=color.black, text_size=size.tiny)
    table.cell(info_table, 1, 6, str.tostring(atr, "#.####"), text_color=color.blue, text_size=size.tiny)
    
    // Fibonacci Range
    table.cell(info_table, 0, 7, "Fib Range:", text_color=color.black, text_size=size.tiny)
    table.cell(info_table, 1, 7, str.tostring(fib_range, "#.####"), text_color=color.orange, text_size=size.tiny)
    
    // Current Position Info
    if strategy.position_size != 0
        current_pnl = strategy.position_size > 0 ? (close - entry_price) / entry_price * 100 : (entry_price - close) / entry_price * 100
        table.cell(info_table, 0, 8, "Current P&L:", text_color=color.black, text_size=size.tiny)
        pnl_color = current_pnl > 0 ? color.green : color.red
        table.cell(info_table, 1, 8, str.tostring(current_pnl, "#.##") + "%", text_color=pnl_color, text_size=size.tiny)
        
        // Risk Amount
        risk_amount = strategy.position_size > 0 ? entry_price - stop_loss : stop_loss - entry_price
        table.cell(info_table, 0, 9, "Risk per Share:", text_color=color.black, text_size=size.tiny)
        table.cell(info_table, 1, 9, str.tostring(risk_amount, "#.####"), text_color=color.orange, text_size=size.tiny)
        
        // Reward Amount
        reward_amount = strategy.position_size > 0 ? take_profit - entry_price : entry_price - take_profit
        table.cell(info_table, 0, 10, "Reward per Share:", text_color=color.black, text_size=size.tiny)
        table.cell(info_table, 1, 10, str.tostring(reward_amount, "#.####"), text_color=color.green, text_size=size.tiny)

// ═══════════════════════════════════════════════════════════════════════════════
// 🔔 ENHANCED ALERT CONDITIONS
// ═══════════════════════════════════════════════════════════════════════════════

// Alert conditions
alertcondition(long_condition, title="🟢 Elite Long Entry Pro", message="Elite Engulfing Strategy PRO: LONG signal detected with commission calculation.")

alertcondition(short_condition, title="🔴 Elite Short Entry Pro", message="Elite Engulfing Strategy PRO: SHORT signal detected with commission calculation.")

// Dynamic alerts with detailed information
if long_condition
    alert_msg = "🟢 LONG SIGNAL: Elite Engulfing Pro | Price: " + str.tostring(close, "#.####") + " | RR: " + str.tostring(rr_ratio, "#.##") + " | SL Type: " + sl_type + " | Commission: " + (enable_commission ? str.tostring(commission_rate, "#.##") + "%" : "Disabled")
    alert(alert_msg, alert.freq_once_per_bar)

if short_condition
    alert_msg = "🔴 SHORT SIGNAL: Elite Engulfing Pro | Price: " + str.tostring(close, "#.####") + " | RR: " + str.tostring(rr_ratio, "#.##") + " | SL Type: " + sl_type + " | Commission: " + (enable_commission ? str.tostring(commission_rate, "#.##") + "%" : "Disabled")
    alert(alert_msg, alert.freq_once_per_bar)