다중 지표 하이브리드 RSI 정량적 단기 거래 전략

RSI EMA VOLUME TREND DETECTION Price Action SCALPING Trailing Stop
생성 날짜: 2025-07-31 11:00:55 마지막으로 수정됨: 2025-07-31 11:00:55
복사: 0 클릭수: 252
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

다중 지표 하이브리드 RSI 정량적 단기 거래 전략 다중 지표 하이브리드 RSI 정량적 단기 거래 전략

개요

다중 지표 혼합 RSI 수량 단선 거래 전략은 여러 기술 지표가 결합된 통합 거래 시스템으로, 단선 거래자를 위해 설계되었다. 이 전략은 RSI 지표, 이동 평균, 거래량 분석 및 가격 행동 패턴을 결합하여 다차원 거래 의사 결정 프레임 워크를 형성한다. 이 전략의 핵심은 다양한 수준의 감수성을 통해 신호 필터링 메커니즘을 통해 거래자가 자신의 위험 선호와 시장 상황에 따라 거래 빈도 및 신호 품질을 조정할 수 있도록 한다. 이 전략은 특히 빠른 진입과 정밀한 출구에 중점을 두고 있으며, 여러 출구 메커니즘을 통해 스톱, 스톱, 손실 추적 및 신속한 출구 기능을 포함하며, 효과적으로 위험을 제어하고 동시에 이익을 잠금합니다.

전략 원칙

이 전략의 핵심 원칙은 다음과 같은 몇 가지 핵심 기술 요소의 상호 작용에 기반합니다.

  1. RSI가 오버 바이 오버 셀 신호14주기 RSI 지표를 사용하여 오버 바이 (<70) 와 오버 세 (<30) 지역을 주요 거래 신호 트리거 조건으로 식별합니다.

  2. 이동 평균 추세가 확인되었습니다.전략: 9, 21, 50 주기의 EMA 이동 평균을 결합하여 트렌드 인식 시스템을 구축한다. 이 평행선 사이의 관계를 관찰하여 시장 트렌드 방향과 강도를 판단한다. EMA9> EMA21> EMA50이있을 때 강력한 상승 트렌드를 확인한다. EMA9< EMA21< EMA50이있을 때 강력한 하락 트렌드를 확인한다.

  3. 수량 검증: 현재 거래량을 10주기 평균 거래량과 비교하여 거래가 충분히 활발한 시장 환경에서 이루어지는 것을 보장하여 신호 품질을 향상시킵니다.

  4. 가격 행동 패턴: 그래프 형태를 분석하고, 특히 강세를 보인 과 을 보인 을 분석하고, 실물과 그림자 선의 비율을 계산하여 가격 동력을 측정한다.

  5. 다단계 신호 민감도이 전략은 4개의 다른 레벨의 신호 감수성을 설계하고 있다. (“ง่ายมาก”, “อ่อน”, “กลาง”, “중심”, “แรง”) 이는 거래자가 시장 조건과 위험 선호에 따라 거래 빈도와 정확도를 조정할 수 있도록 한다.

  6. 스마트 출전 메커니즘이 전략은 여러 가지 출전 메커니즘을 구현합니다. 고정된 스톱 스톱 손실, RSI 반전 신호의 빠른 퇴출 및 트래킹 스톱 손실 기능으로 스톱 손실 가격을 동적으로 조정하여 이미 얻은 수익을 잠금합니다.

  7. 하루 거래량 제한: 내장된 일일 거래 수 제한 기능, 과도한 거래를 방지하고, 단선 거래의 스타일 특성에 부합한다.

전략적 이점

  1. 유연한 신호 민감도 조정전략의 가장 큰 장점은 조정 가능한 신호 민감도 시스템으로, 거래자는 “매우 쉬운”에서 “강렬한”의 네 가지 수준에서 거래 빈도와 신호 품질 사이의 균형을 찾을 수 있습니다. 이것은 전략이 다른 시장 환경과 개인 거래 스타일에 적응 할 수있게합니다.

  2. 다중 위험 관리 메커니즘이 전략은 고정 스톱, 추적 스톱 및 RSI 기반의 빠른 퇴출과 같은 여러 위험 제어 방법을 통합하여 전체적인 위험 관리 프레임 워크를 제공합니다. 특히, 추적 스톱 기능은 수익 성장 공간을 유지하면서 점진적으로 수익을 고정 할 수 있습니다.

  3. 전체 기술 지표 통합RSI, EMA, 거래량 및 가격 행동 분석을 결합하여, 전략은 여러 차원에서 시장 상황을 평가하고, 가짜 신호의 발생을 줄이고, 거래의 정확성을 향상시킬 수 있습니다.

  4. 자동 거래 실행전략은 완전히 자동화되어 신호 생성, 입출장 결정에서 출장 관리에 이르기까지 인간의 감정적 간섭을 줄이고 거래 규율을 보장합니다.

  5. 실시간 시각적 피드백내장된 디스플레이 기능을 통해 거래자는 전략의 성과, 현재 시장 상태 및 거래 상태를 직관적으로 모니터링하여 실시간 의사결정을 조정할 수 있습니다.

  6. 통신 통합 능력전략: 텔레그램의 메세지 푸싱 기능, 원격 거래 모니터링 및 신호 알림, 운영 편의성 향상.

전략적 위험

  1. RSI의 한계: RSI는 주요 신호 소스로, 지연 및 가짜 신호의 위험이 있습니다, 특히 흔들리는 시장에서 자주 잘못된 신호를 생성 할 수 있습니다. 해결책은 트렌드 필터와 가격 행동 확인을 결합하거나横盘 시장에서 신호 민감성 요구 사항을 높이는 것입니다.

  2. 과대 최적화 위험: RSI 미지수, EMA 주기, 스톱 스톱 손실 비율 등과 같은 전략 매개 변수가 많기 때문에 과도한 최적화를 초래할 수 있습니다. 역사적 데이터 재검토 및 전향 테스트를 통해 매개 변수의 안정성을 검증하는 것이 좋습니다.

  3. 빠른 시장의 위험: 높은 변동성이나 시장 폭락의 상황에서 고정된 스톱로드는 효과적으로 실행되지 않을 수 있으며, 실제 손실이 예상보다 더 많을 수 있습니다. 이 위험에 대응하기 위해 변동률 조정 스톱 레벨을 사용하거나 시장의 변동 필터 조건을 증가시키는 것을 고려하십시오.

  4. 거래 빈도 위험: 특히 낮은 민감도 설정 하에서, 전략은 거래 신호를 너무 많이 생성하고 거래 비용을 증가시킬 수 있습니다. 거래 주파수를 합리적으로 설정하여 일일 거래 제한을 설정하고 신호 민감도를 조정하여 제어합니다.

  5. 이 추세는 뒤집을 수 없습니다.: EMA 판단에 의존하는 경향은 트렌드 반전의 초기에는 충분히 빠르게 반응하지 않을 수 있습니다. ADX 또는 Parabolic SAR와 같은 다른 경향 확인 지표와 결합하여 트렌드 식별 능력을 향상시키는 것이 좋습니다.

전략 최적화 방향

  1. 적응 변수 조정: 현재 전략은 고정된 RSI 마이너스값과 EMA 주기를 사용하며, 시장의 변동성에 기반한 자기 적응 파라미터 시스템을 도입할 수 있다. 예를 들어, 높은 변동성 시장에서 RSI의 오버 바이 오버 소드 마이너스를 자동으로 조정하거나, 다른 시간 프레임의 동력에 따라 EMA 주기의 길이를 조정하여 전략의 다양한 시장 환경에 대한 적응성을 향상시킬 수 있다.

  2. 강화된 신호 필터링 메커니즘: 더 많은 차원의 시장 환경 식별 지표가 도입 될 수 있습니다. 예를 들어 ATR ((평균 실제 파도) 가 변동률을 평가하고 ADX ((평균 방향 지수) 가 트렌드 강도를 확인하거나 다중 시간 프레임 분석을 사용하여 신호 품질을 향상시킵니다. 이러한 추가 필터는 가짜 신호를 줄이고 거래 성공률을 향상시킵니다.

  3. 자금 관리 시스템을 최적화: 현재 전략의 포지션 관리는 비교적 간단하며, 계좌의 순가치 퍼센트에 기반한 동적 포지션 조정이나 켈리 원칙에 기반한 자금 배분 방법을 도입할 수 있다. 따라서 역사적인 거래 성과와 현재 시장 상황에 따라 각 거래의 위험 경계를 자동으로 조정할 수 있다.

  4. 기계 학습 요소를 추가합니다.: 기계 학습 알고리즘을 사용하여 역사적 거래 데이터를 분석하여 다양한 시장 환경에서 전략의 최적의 배열을 자동으로 식별 할 수 있습니다. 감시 학습 또는 강제 학습 방법을 통해 신호 신뢰성을 예측할 수있는 모델을 구축하여 거래 의사 결정의 질을 더욱 향상시킵니다.

  5. 확장 시장 상태 분류: 더 세밀한 시장 상태 분류 시스템을 개발할 수 있습니다. 트렌드, 간격 흔들림, 높은 변동 등과 같은, 각 시장 상태에 대한 거래 규칙과 파라미터를 맞춤화합니다. 이러한 계층화 전략 프레임 워크는 다른 시장 환경에 더 잘 대응합니다.

요약하다

다중 지표 혼합 RSI 수량 단선 거래 전략은 RSI, 이동 평균, 거래량 및 가격 행동 분석을 통합하여 다차원 거래 의사 결정 프레임워크를 구축하는 포괄적이고 유연한 단선 거래 시스템입니다. 가장 큰 장점은 유연하고 조정 가능한 신호 민감성 시스템과 다중 위험 관리 장치로 거래자가 시장 환경과 개인 위험 선호도에 따라 거래 전략을 맞춤화 할 수 있습니다.

RSI 지표의 제한과 변수 최적화와 같은 잠재적인 위험이 있음에도 불구하고, 적절한 위험 관리와 지속적인 최적화를 통해 이러한 위험을 효과적으로 제어 할 수 있습니다. 미래 최적화 방향은 변수 자조, 신호 필터 강화, 자금 관리 최적화 및 기계 학습과 같은 첨단 기술을 도입하여 전략의 안정성과 적응성을 더욱 향상시키는 데 중점을 두어야합니다.

전체적으로, 이것은 합리적으로 설계된, 구조가 잘 갖춰진, 실용적인 가치와 유연성이 높은 양적 거래 전략이다. 단선 거래 기회를 찾고, 위험을 통제하는 거래자에게는, 이 시스템은 좋은 출발점을 제공하며, 지속적인 테스트와 조정을 통해 안정적이고 신뢰할 수 있는 거래 도구로 발전할 수 있다.

전략 소스 코드
/*backtest
start: 2024-07-31 00:00:00
end: 2025-07-29 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("🔥 HYBRID SCALPING Bot - เข้าง่าย ออกแม่น", overlay=true, max_labels_count=50, calc_on_order_fills=false, process_orders_on_close=true, pyramiding=0)

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 📋 การตั้งค่าแบบ Hybrid - รวมจุดเด่นทั้งสอง
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

// การตั้งค่าเทรด - Scalping Style
group_trading = "⚡ การตั้งค่า Scalping"
daily_trade_limit = input.int(15, "ลิมิตเทรดต่อวัน", minval=5, maxval=50, tooltip="Scalping = เทรดบ่อย", group=group_trading)
tp_percent = input.float(0.8, "Take Profit %", minval=0.3, maxval=3.0, tooltip="เล็กแต่ชัวร์", group=group_trading)
sl_percent = input.float(0.6, "Stop Loss %", minval=0.3, maxval=2.0, tooltip="ตัดขาดทุนเร็ว", group=group_trading)

// การตั้งค่าการออกเทรด - จาก Scalping Bot
use_quick_exit = input.bool(true, "ออกเทรดเร็ว", tooltip="ออกเมื่อ RSI กลับตัว", group=group_trading)
use_trailing_stop = input.bool(true, "ใช้ Trailing Stop", tooltip="ล็อคกำไรเมื่อขึ้น", group=group_trading)
trailing_percent = input.float(0.4, "Trailing Stop %", minval=0.2, maxval=1.0, group=group_trading)

// ความยากง่ายในการเข้าเทรด - จาก Debug Bot
group_sensitivity = "🎯 ความยากง่ายการเข้าเทรด"
signal_sensitivity = input.string("อ่อน", "ระดับความรุนแรง", options=["ง่ายมาก", "อ่อน", "กลาง", "แรง"], 
                                  tooltip="ง่ายมาก=เข้าเทรดบ่อยสุด, แรง=แม่นยำสุด", group=group_sensitivity)

// ฟิลเตอร์เสริม - ปรับได้ตามระดับ
use_trend_filter = input.bool(true, "ใช้ฟิลเตอร์เทรนด์", tooltip="เทรดตามเทรนด์เท่านั้น", group=group_sensitivity)
use_volume_filter = input.bool(false, "ใช้ฟิลเตอร์ Volume", tooltip="ต้องมี Volume สูง", group=group_sensitivity)

// การแสดงผล
group_display = "🎨 การแสดงผล"
show_signals = input.bool(true, "แสดงสัญญาณ", group=group_display)
show_exit_signals = input.bool(true, "แสดงสัญญาณออก", group=group_display)
show_dashboard = input.bool(true, "แสดง Dashboard", group=group_display)

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 📱 การตั้งค่า Telegram - แบบง่าย (จาก Debug Bot)
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

group_telegram = "📱 Telegram"
enable_telegram = input.bool(false, "เปิด Telegram", group=group_telegram)
telegram_bot_token = input.string("", "Bot Token", group=group_telegram)
telegram_chat_id = input.string("", "Chat ID", group=group_telegram)
send_test_message = input.bool(false, "ส่งข้อความทดสอบ", group=group_telegram)

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 🧮 ตัวชี้วัดเทคนิค - Hybrid
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

// RSI
rsi = ta.rsi(close, 14)
rsi_oversold = 30
rsi_overbought = 70

// Moving Averages
ema9 = ta.ema(close, 9)
ema21 = ta.ema(close, 21)
ema50 = ta.ema(close, 50)

// Trend
uptrend = ema21 > ema50
downtrend = ema21 < ema50
strong_uptrend = ema9 > ema21 and ema21 > ema50
strong_downtrend = ema9 < ema21 and ema21 < ema50

// Volume
avg_volume = ta.sma(volume, 10)
high_volume = volume > avg_volume * 1.2
volume_ok = use_volume_filter ? high_volume : true

// Price Action
bullish_candle = close > open
bearish_candle = close < open
strong_bullish_candle = close > open and (close - open) / (high - low) > 0.6
strong_bearish_candle = close < open and (open - close) / (high - low) > 0.6

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 🎯 ระบบสัญญาณแบบ Hybrid
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

// ระดับ "ง่ายมาก" - เข้าเทรดง่ายสุด
very_easy_buy = rsi < 60 and bullish_candle
very_easy_sell = rsi > 40 and bearish_candle

// ระดับ "อ่อน" - ใช้ RSI หลัก
easy_buy = rsi < rsi_oversold and bullish_candle
easy_sell = rsi > rsi_overbought and bearish_candle

// ระดับ "กลาง" - เพิ่มเงื่อนไข Trend
medium_buy = rsi < rsi_oversold and bullish_candle and (use_trend_filter ? uptrend : true)
medium_sell = rsi > rsi_overbought and bearish_candle and (use_trend_filter ? downtrend : true)

// ระดับ "แรง" - เงื่อนไขครบ (เหมือน Scalping Bot เดิม)
strong_buy = rsi < rsi_oversold and 
             strong_bullish_candle and 
             (use_trend_filter ? strong_uptrend : true) and 
             volume_ok and 
             close > ema21

strong_sell = rsi > rsi_overbought and 
              strong_bearish_candle and 
              (use_trend_filter ? strong_downtrend : true) and 
              volume_ok and 
              close < ema21

// เลือกสัญญาณตามระดับที่ตั้งค่า
buy_signal = signal_sensitivity == "ง่ายมาก" ? very_easy_buy :
             signal_sensitivity == "อ่อน" ? easy_buy :
             signal_sensitivity == "กลาง" ? medium_buy :
             strong_buy

sell_signal = signal_sensitivity == "ง่ายมาก" ? very_easy_sell :
              signal_sensitivity == "อ่อน" ? easy_sell :
              signal_sensitivity == "กลาง" ? medium_sell :
              strong_sell

// Exit Signals - ใช้จาก Scalping Bot
rsi_exit_long = rsi > 70 or rsi < 25
rsi_exit_short = rsi < 30 or rsi > 75

quick_exit_long = use_quick_exit and (rsi_exit_long or close < ema21)
quick_exit_short = use_quick_exit and (rsi_exit_short or close > ema21)

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 📊 การจัดการเทรด
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

var int trades_today = 0
var bool test_sent = false

// รีเซ็ตทุกวัน
if dayofweek != dayofweek[1]
    trades_today := 0

can_trade = trades_today < daily_trade_limit and strategy.position_size == 0

// ส่งข้อความทดสอบ Telegram - ใช้ format จาก Debug Bot
if enable_telegram and send_test_message and not test_sent and barstate.islast
    test_message = "🧪 ทดสอบ HYBRID SCALPING Bot\n\n" +
                   "✅ การเชื่อมต่อสำเร็จ!\n" +
                   "📊 Symbol: " + syminfo.ticker + "\n" +
                   "💲 ราคาปัจจุบัน: $" + str.tostring(close, "#.####") + "\n" +
                   "⚡ ระดับ: " + signal_sensitivity + "\n" +
                   "⏰ เวลา: " + str.tostring(hour, "00") + ":" + str.tostring(minute, "00") + "\n\n" +
                   "🎯 Bot พร้อมทำงาน!"
    
    alert(test_message, alert.freq_once_per_bar)
    test_sent := true

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 💰 การดำเนินการเทรด - Scalping Logic
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

// Variables for Scalping
var float entry_price = 0
var float highest_profit = 0
var float trailing_stop_price = 0

// Entry Long
if buy_signal and can_trade
    strategy.entry("LONG", strategy.long)
    trades_today := trades_today + 1
    entry_price := close
    highest_profit := 0
    trailing_stop_price := close * (1 - sl_percent / 100)
    
    // Set exits
    strategy.exit("SL/TP", "LONG", 
                  stop=close * (1 - sl_percent / 100), 
                  limit=close * (1 + tp_percent / 100))
    
    // Telegram Alert - ใช้ format ง่าย
    if enable_telegram
        entry_message = "🚀 HYBRID LONG!\n" +
                       "📊 " + syminfo.ticker + "\n" +
                       "💰 Entry: $" + str.tostring(close, "#.####") + "\n" +
                       "🛑 SL: $" + str.tostring(close * (1 - sl_percent / 100), "#.####") + "\n" +
                       "🎯 TP: $" + str.tostring(close * (1 + tp_percent / 100), "#.####") + "\n" +
                       "📈 RSI: " + str.tostring(rsi, "#.#") + "\n" +
                       "⚡ Level: " + signal_sensitivity + "\n" +
                       "📊 เทรดที่: " + str.tostring(trades_today)
        
        alert(entry_message, alert.freq_once_per_bar)

// Entry Short
if sell_signal and can_trade
    strategy.entry("SHORT", strategy.short)
    trades_today := trades_today + 1
    entry_price := close
    highest_profit := 0
    trailing_stop_price := close * (1 + sl_percent / 100)
    
    // Set exits
    strategy.exit("SL/TP", "SHORT", 
                  stop=close * (1 + sl_percent / 100), 
                  limit=close * (1 - tp_percent / 100))
    
    // Telegram Alert
    if enable_telegram
        entry_message = "📉 HYBRID SHORT!\n" +
                       "📊 " + syminfo.ticker + "\n" +
                       "💰 Entry: $" + str.tostring(close, "#.####") + "\n" +
                       "🛑 SL: $" + str.tostring(close * (1 + sl_percent / 100), "#.####") + "\n" +
                       "🎯 TP: $" + str.tostring(close * (1 - tp_percent / 100), "#.####") + "\n" +
                       "📈 RSI: " + str.tostring(rsi, "#.#") + "\n" +
                       "⚡ Level: " + signal_sensitivity + "\n" +
                       "📊 เทรดที่: " + str.tostring(trades_today)
        
        alert(entry_message, alert.freq_once_per_bar)

// Trailing Stop Logic - จาก Scalping Bot
if strategy.position_size > 0 and use_trailing_stop  // Long position
    current_profit = (close - entry_price) / entry_price * 100
    if current_profit > highest_profit
        highest_profit := current_profit
        trailing_stop_price := close * (1 - trailing_percent / 100)
    
    if close <= trailing_stop_price
        strategy.close("LONG", comment="Trailing Stop")
        if enable_telegram
            exit_message = "🔒 TRAILING STOP LONG!\n" +
                          "📊 " + syminfo.ticker + "\n" +
                          "💰 Exit: $" + str.tostring(close, "#.####") + "\n" +
                          "📈 Profit: +" + str.tostring(current_profit, "#.##") + "%"
            alert(exit_message, alert.freq_once_per_bar)

if strategy.position_size < 0 and use_trailing_stop  // Short position
    current_profit = (entry_price - close) / entry_price * 100
    if current_profit > highest_profit
        highest_profit := current_profit
        trailing_stop_price := close * (1 + trailing_percent / 100)
    
    if close >= trailing_stop_price
        strategy.close("SHORT", comment="Trailing Stop")
        if enable_telegram
            exit_message = "🔒 TRAILING STOP SHORT!\n" +
                          "📊 " + syminfo.ticker + "\n" +
                          "💰 Exit: $" + str.tostring(close, "#.####") + "\n" +
                          "📈 Profit: +" + str.tostring(current_profit, "#.##") + "%"
            alert(exit_message, alert.freq_once_per_bar)

// Quick Exit Logic - จาก Scalping Bot
if strategy.position_size > 0 and quick_exit_long
    strategy.close("LONG", comment="Quick Exit")
    if enable_telegram
        current_pnl = (close - entry_price) / entry_price * 100
        exit_message = "⚡ QUICK EXIT LONG!\n" +
                      "📊 " + syminfo.ticker + "\n" +
                      "💰 Exit: $" + str.tostring(close, "#.####") + "\n" +
                      "📈 P&L: " + str.tostring(current_pnl, "#.##") + "%"
        alert(exit_message, alert.freq_once_per_bar)

if strategy.position_size < 0 and quick_exit_short
    strategy.close("SHORT", comment="Quick Exit")
    if enable_telegram
        current_pnl = (entry_price - close) / entry_price * 100
        exit_message = "⚡ QUICK EXIT SHORT!\n" +
                      "📊 " + syminfo.ticker + "\n" +
                      "💰 Exit: $" + str.tostring(close, "#.####") + "\n" +
                      "📈 P&L: " + str.tostring(current_pnl, "#.##") + "%"
        alert(exit_message, alert.freq_once_per_bar)

// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════
// 🎨 การแสดงผลบนชาร์ต
// ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════

// Plot signals
plotshape(buy_signal and show_signals, "Buy", shape.triangleup, location.belowbar, color.lime, size=size.small)
plotshape(sell_signal and show_signals, "Sell", shape.triangledown, location.abovebar, color.red, size=size.small)

// Plot exit signals
plotshape(quick_exit_long and show_exit_signals, "Quick Exit Long", shape.xcross, location.abovebar, color.orange, size=size.tiny)
plotshape(quick_exit_short and show_exit_signals, "Quick Exit Short", shape.xcross, location.belowbar, color.orange, size=size.tiny)

// Plot EMAs
plot(ema21, "EMA21", color.blue, linewidth=1)
plot(ema50, "EMA50", color.purple, linewidth=1)

// Dashboard - ปรับปรุงให้ปลอดภัย
if show_dashboard and barstate.islast
    var table dashboard = table.new(position.top_right, 2, 7, bgcolor=color.white, border_width=1)
    
    table.cell(dashboard, 0, 0, "🔥 HYBRID", text_color=color.white, bgcolor=color.orange, text_size=size.small)
    table.cell(dashboard, 1, 0, syminfo.ticker, text_color=color.white, bgcolor=color.orange, text_size=size.small)
    
    table.cell(dashboard, 0, 1, "💰 P&L", text_color=color.black, text_size=size.small)
    pnl_value = strategy.netprofit
    pnl_color = pnl_value >= 0 ? color.green : color.red
    table.cell(dashboard, 1, 1, "$" + str.tostring(pnl_value, "#.##"), text_color=pnl_color, text_size=size.small)
    
    table.cell(dashboard, 0, 2, "⚡ Level", text_color=color.black, text_size=size.small)
    table.cell(dashboard, 1, 2, signal_sensitivity, text_color=color.purple, text_size=size.small)
    
    table.cell(dashboard, 0, 3, "📈 RSI", text_color=color.black, text_size=size.small)
    rsi_color = rsi < 30 ? color.green : rsi > 70 ? color.red : color.gray
    table.cell(dashboard, 1, 3, str.tostring(rsi, "#.#"), text_color=rsi_color, text_size=size.small)
    
    table.cell(dashboard, 0, 4, "📊 เทรด", text_color=color.black, text_size=size.small)
    table.cell(dashboard, 1, 4, str.tostring(trades_today) + "/" + str.tostring(daily_trade_limit), text_color=color.navy, text_size=size.small)
    
    table.cell(dashboard, 0, 5, "📍 สถานะ", text_color=color.black, text_size=size.small)
    position_text = strategy.position_size > 0 ? "LONG" : strategy.position_size < 0 ? "SHORT" : "ว่าง"
    position_color = strategy.position_size > 0 ? color.green : strategy.position_size < 0 ? color.red : color.gray
    table.cell(dashboard, 1, 5, position_text, text_color=position_color, text_size=size.small)
    
    table.cell(dashboard, 0, 6, "🎯 Trend", text_color=color.black, text_size=size.small)
    trend_text = uptrend ? "UP" : downtrend ? "DOWN" : "SIDE"
    trend_color = uptrend ? color.green : downtrend ? color.red : color.gray
    table.cell(dashboard, 1, 6, trend_text, text_color=trend_color, text_size=size.small)