Thứ Ba, 01/12/202601/12/2026

Hướng Dẫn Sử Dụng Bot CNPS74 - RSI Failure Swing V2 cho VN30F1M

Bot CNPS74 RSI Failure Swing V2 bắt đảo chiều theo cấu trúc 4 giai đoạn của RSI kết hợp hàng chờ xác nhận Price Action, bộ lọc ADX/Volume/H1 EMA và quản trị SL/TP cố định 5–10 điểm cho VN30F1M.

Hướng dẫn sử dụng Bot CNPS74 cho VN30F1M
Hướng dẫn sử dụng Bot CNPS74 cho VN30F1M
Mục lục
Mục lục

Khi giao dịch hợp đồng tương lai VN30F1M, việc bắt đáy hoặc bắt đỉnh chỉ dựa vào tín hiệu RSI chạm vùng quá bán (< 30) hay quá mua (> 70) thường dẫn đến rủi ro “bắt dao rơi” khi thị trường vẫn đang trong xu hướng mạnh. CNPS74 giải quyết bài toán này bằng cách yêu cầu chỉ báo RSI phải hoàn thành cấu trúc Failure Swing (tạo đáy sau cao hơn đáy trước hoặc đỉnh sau thấp hơn đỉnh trước và phá vỡ điểm phản ứng), sau đó mới chuyển sang trạng thái chờ xác nhận từ hành động giá thực tế.

Chiến lược CNPS74 RSI FAILURE SWING V2 được viết bằng Pine Script v6 trên TradingView, kết hợp giữa máy trạng thái cấu trúc RSI và hàng chờ xác nhận nến, đi kèm các bộ lọc ngữ cảnh tùy chọn nhằm tối ưu hóa tỷ lệ thắng trên khung thời gian ngắn của VN30F1M.

Những điểm nổi bật cốt lõi của Bot CNPS74:

  • Máy trạng thái RSI Failure Swing 4 giai đoạn: Theo dõi chặt chẽ từ lúc RSI đi vào vùng cực trị, phục hồi, tạo nhịp kéo ngược (pullback) hợp lệ cho tới khi phá vỡ ngưỡng phản ứng kèm vùng đệm breakoutBufferRSI.
  • Hàng chờ xác nhận hành động giá (Price Confirmation Queue): Tín hiệu RSI Break chưa vào lệnh ngay mà mở cửa sổ chờ tối đa priceConfirmationBars nến để xác nhận hướng nến, phá vỡ đỉnh/đáy nến trước và tùy chọn vượt đường EMA.
  • Bộ lọc đa tầng linh hoạt: Hỗ trợ lọc nhiễu xu hướng bằng ADX (maximumADX), lọc dòng tiền bằng Volume Spike và lọc xu hướng lớn khung H1 (H1 EMA Bias) không bị repaint.
  • Quản trị rủi ro kỷ luật: Thiết lập sẵn Stop Loss 5 điểm, Take Profit 10 điểm (tỷ lệ R:R 1:2), giới hạn tối đa số lệnh trong ngày, thời gian nghỉ (Cooldown) sau khi đóng lệnh và tự động đóng toàn bộ vị thế trước giờ ATC (14:45).

1. CNPS74 RSI Failure Swing V2 là gì?

CNPS74 RSI Failure Swing V2 là hệ thống giao dịch tự động theo trường phái đảo chiều có xác nhận (Confirmed Mean-Reversion / Failure Swing), vận hành dựa trên 4 trụ cột kỹ thuật chính:

  1. Cấu trúc RSI Failure Swing (4 Stages): Thay vì mua ngay khi RSI < 30 hoặc bán ngay khi RSI > 70, bot theo dõi 4 trạng thái (0 -> 1 -> 2 -> 3) để đảm bảo động lượng đã thực sự đảo chiều và tạo được cấu trúc cao hơn/thấp hơn trên RSI trong giới hạn maximumSetupBars (25 nến).
  2. Xác nhận Hành động Giá (Price Action Confirmation): Sau khi có tín hiệu bullRSIBreak hoặc bearRSIBreak, bot kích hoạt cờ chờ (pendingLong / pendingShort) trong tối đa 3 nến (priceConfirmationBars), yêu cầu nến đóng cửa đúng chiều và vượt đỉnh/đáy nến liền trước (cùng tùy chọn nằm trên/dưới EMA 20).
  3. Bộ lọc Ngữ cảnh Thị trường (Regime & Trend Filters): Tích hợp 3 bộ lọc độc lập (tắt mặc định để người dùng tùy biến): bộ lọc sức mạnh xu hướng ADX (useADXFilter), bộ lọc đột biến khối lượng (requireVolumeSpike) và bộ lọc xu hướng khung 60 phút (useH1EMABias).
  4. Kiểm soát Phiên & Quản trị Vốn (Session & Risk Engine): Giới hạn mặc định tối đa 2 lệnh/ngày, thời gian nghỉ 5 nến sau khi thoát lệnh, cắt lỗ cố định 5 điểm, chốt lời 10 điểm, tùy chọn thoát lệnh theo thời gian giữ (useTimeExit) và tự động tất toán vị thế vào cuối phiên (14:45 giờ Việt Nam).

Bảng thông số mặc định

Nhóm thông sốTên biến (input)Giá trị mặc địnhÝ nghĩa trong chiến lược
RSIrsiLength14Chu kỳ tính chỉ báo RSI
RSIoversoldLevel / overboughtLevel30 / 70Ngưỡng quá bán và quá mua
Failure SwingminimumPullbackRSI5.0Biên độ hồi tối thiểu của RSI để xác nhận nhịp pullback
Failure SwingmaximumSetupBars25Số nến tối đa để hoàn thành một mẫu hình Failure Swing
Failure SwingbreakoutBufferRSI0.5Vùng đệm cộng thêm khi RSI phá vỡ điểm phản ứng
Price ConfirmationrequirePriceBreaktrueYêu cầu giá đóng cửa vượt high[1] (Long) hoặc thủng low[1] (Short)
Price ConfirmationrequireCandleDirectiontrueYêu cầu nến xác nhận là nến tăng (close > open) hoặc giảm (close < open)
Price ConfirmationpriceConfirmationBars3Số nến tối đa cho phép chờ xác nhận giá sau khi RSI Break
Price ConfirmationuseEMAReclaim / emaLengthfalse / 20Tùy chọn yêu cầu giá đóng cửa trên/dưới đường EMA 20
ADXuseADXFilterfalseBật/tắt bộ lọc giới hạn ADX
ADXdiLength / adxSmoothing / maximumADX14 / 14 / 30.0Chu kỳ DMI/ADX và ngưỡng ADX tối đa cho phép vào lệnh
VolumerequireVolumeSpikefalseBật/tắt điều kiện khối lượng đột biến
VolumevolumeAverageLength / volumeSpikeFactor20 / 1.2Chu kỳ SMA khối lượng và hệ số nhân đột biến
H1 TrenduseH1EMABias / h1EMALengthfalse / 50Lọc xu hướng theo nến H1 đã đóng cửa so với EMA 50 khung H1
Risk ManagementstopLossPoints / takeProfitPoints5.0 / 10.0Mức Cắt lỗ (5 điểm) và Chốt lời (10 điểm) cố định
Risk ManagementuseTimeExit / maximumHoldingBarsfalse / 20Tùy chọn đóng lệnh nếu giữ quá số nến tối đa
Trade ControlmaximumTradesPerDay2Số lệnh tối đa được phép mở trong một ngày
Trade ControltradeDirection"Long"Chiều giao dịch ("Long", "Short", "Both")
Trade ControlcooldownBars5Số nến nghỉ tối thiểu sau khi đóng vị thế trước
SessionuseSessionFilterfalseBật/tắt lọc khung giờ vào lệnh (09:15 – 14:15)
SessionsessionEndHour : sessionEndMinute14:45Giờ bắt buộc đóng toàn bộ vị thế cuối phiên (Asia/Ho_Chi_Minh)
Alerts & DisplaydisableSLTPAlerts / showDiagnosticsfalse / falseTắt cảnh báo SL/TP; bật/tắt bảng chẩn đoán trên góc phải màn hình

Source Code CNPS74 RSI Failure Swing V2

Bạn có thể sao chép toàn bộ mã nguồn Pine Script v6 dưới đây để dán trực tiếp vào Pine Editor trên TradingView:

//@version=6
strategy(title="CNPS74 RSI FAILURE SWING V2", shorttitle="CNPS74 RSI FS V2", overlay=true, initial_capital=100000000, default_qty_type=strategy.fixed, default_qty_value=1, pyramiding=0, margin_long=0, margin_short=0, slippage=0, commission_type=strategy.commission.cash_per_contract, commission_value=0, fill_orders_on_standard_ohlc=true, process_orders_on_close=true, calc_on_order_fills=true, max_labels_count=300, max_lines_count=300, max_bars_back=5000)

// ============================================================================
// CNPS74 RSI FAILURE SWING V2
// RSI STRUCTURE + PRICE CONFIRMATION
//
// LONG:
// RSI BELOW OVERSOLD
// -> RECOVERY
// -> RSI HIGHER LOW
// -> RSI BREAKS REACTION HIGH
// -> WAIT FOR PRICE CONFIRMATION
// -> LONG
//
// SHORT: REVERSE
//
// DEFAULT SL = 5 POINTS
// DEFAULT TP = 10 POINTS
// ============================================================================
// ============================================================================
// SECTION 1: RSI
// ============================================================================
rsiLength = input.int(14, "RSI Length", minval=2, group="RSI")
oversoldLevel = input.float(30, "Oversold Level", minval=1, maxval=49, group="RSI")
overboughtLevel = input.float(70, "Overbought Level", minval=51, maxval=99, group="RSI")

// ============================================================================
// SECTION 2: FAILURE SWING
// ============================================================================
minimumPullbackRSI = input.float(5.0, "Minimum RSI Pullback", minval=0.5, step=0.5, group="Failure Swing")
maximumSetupBars = input.int(25, "Maximum Setup Bars", minval=5, maxval=200, group="Failure Swing")
breakoutBufferRSI = input.float(0.5, "RSI Breakout Buffer", minval=0, step=0.5, group="Failure Swing")

// ============================================================================
// SECTION 3: PRICE CONFIRMATION
// ============================================================================
requirePriceBreak = input.bool(true, "Require Previous High / Low Break?", group="Price Confirmation")
requireCandleDirection = input.bool(true, "Require Bullish / Bearish Candle?", group="Price Confirmation")
priceConfirmationBars = input.int(3, "Max Bars For Price Confirmation", minval=0, maxval=20, group="Price Confirmation")
useEMAReclaim = input.bool(false, "Require EMA20 Reclaim?", group="Price Confirmation")
emaLength = input.int(20, "EMA Length", minval=1, group="Price Confirmation")

// ============================================================================
// SECTION 4: ADX FILTER
// ============================================================================
useADXFilter = input.bool(false, "Use ADX Regime Filter?", group="ADX")
diLength = input.int(14, "DI Length", minval=2, group="ADX")
adxSmoothing = input.int(14, "ADX Smoothing", minval=2, group="ADX")
maximumADX = input.float(30.0, "Maximum ADX", minval=1, step=1, group="ADX")

// ============================================================================
// SECTION 5: VOLUME FILTER
// ============================================================================
requireVolumeSpike = input.bool(false, "Require Volume Spike?", group="Volume")
volumeAverageLength = input.int(20, "Volume Average Length", minval=2, group="Volume")
volumeSpikeFactor = input.float(1.2, "Volume Spike Factor", minval=0.1, step=0.1, group="Volume")

// ============================================================================
// SECTION 6: H1 BIAS
// ============================================================================
useH1EMABias = input.bool(false, "Use Confirmed H1 EMA Bias?", group="H1 Trend")
h1EMALength = input.int(50, "H1 EMA Length", minval=1, group="H1 Trend")

// ============================================================================
// SECTION 7: RISK MANAGEMENT
// ============================================================================
stopLossPoints = input.float(5.0, "Stop Loss (Points)", minval=0.1, step=0.5, group="Risk Management")
takeProfitPoints = input.float(10.0, "Take Profit (Points)", minval=0.1, step=0.5, group="Risk Management")
useTimeExit = input.bool(false, "Use Maximum Holding Bars?", group="Risk Management")
maximumHoldingBars = input.int(20, "Maximum Holding Bars", minval=1, maxval=200, group="Risk Management")

// ============================================================================
// SECTION 8: TRADE CONTROL
// ============================================================================
maximumTradesPerDay = input.int(2, "Maximum Trades Per Day", minval=1, maxval=20, group="Trade Control")
tradeDirection = input.string("Long", "Trade Direction", options=["Long", "Short", "Both"], group="Trade Control")
cooldownBars = input.int(5, "Cooldown Bars After Exit", minval=0, maxval=100, group="Trade Control")
bool allowLong = (tradeDirection == "Long" or tradeDirection == "Both")
bool allowShort = (tradeDirection == "Short" or tradeDirection == "Both")

// ============================================================================
// SECTION 9: SESSION
// ============================================================================
useSessionFilter = input.bool(false, "Use Entry Session Filter?", group="Session")
strategyTimezone = input.string("Asia/Ho_Chi_Minh", "Strategy Timezone", group="Session")
sessionStartHour = input.int(9, "Session Start Hour", minval=0, maxval=23, group="Session")
sessionStartMinute = input.int(15, "Session Start Minute", minval=0, maxval=59, group="Session")
lastEntryHour = input.int(14, "Last Entry Hour", minval=0, maxval=23, group="Session")
lastEntryMinute = input.int(15, "Last Entry Minute", minval=0, maxval=59, group="Session")
sessionEndHour = input.int(14, "Force Close Hour", minval=0, maxval=23, group="Session")
sessionEndMinute = input.int(45, "Force Close Minute", minval=0, maxval=59, group="Session")

// ============================================================================
// SECTION 10: ALERTS
// ============================================================================
disableSLTPAlerts = input.bool(false, "Disable SL / TP Alerts?", group="Alerts")

// ============================================================================
// SECTION 11: DISPLAY
// ============================================================================
showEMA = input.bool(true, "Show EMA?", group="Display")
showSignalMarkers = input.bool(true, "Show Setup Markers?", group="Display")
showActiveSLTP = input.bool(true, "Show Active SL / TP?", group="Display")
showDiagnostics = input.bool(false, "Show Diagnostics?", group="Display")

// ============================================================================
// SECTION 12: TIME ENGINE
// ============================================================================
int currentMinute = (hour(time, strategyTimezone) * 60 + minute(time, strategyTimezone))
int currentCloseMinute = (hour(time_close, strategyTimezone) * 60 + minute(time_close, strategyTimezone))
int sessionStartTotal = (sessionStartHour * 60 + sessionStartMinute)
int lastEntryTotal = (lastEntryHour * 60 + lastEntryMinute)
int sessionEndTotal = (sessionEndHour * 60 + sessionEndMinute)
bool sessionOK = (not useSessionFilter or (currentMinute >= sessionStartTotal and currentCloseMinute <= lastEntryTotal))

// ============================================================================
// SECTION 13: TRADING DAY
// ============================================================================
int tradingDayKey = (year(time, strategyTimezone) * 10000 + month(time, strategyTimezone) * 100 + dayofmonth(time, strategyTimezone))
bool newTradingDay = (bar_index == 0 or tradingDayKey != tradingDayKey[1])
var int tradesToday = 0
if newTradingDay
    tradesToday := 0

// ============================================================================
// SECTION 14: INDICATOR ENGINE
// ============================================================================
float rsi = ta.rsi(close, rsiLength)
float ema = ta.ema(close, emaLength)
[diPlus, diMinus, adx] = ta.dmi(diLength, adxSmoothing)
float averageVolume = ta.sma(volume, volumeAverageLength)
bool volumeOK = (not requireVolumeSpike or (not na(averageVolume) and volume >= averageVolume * volumeSpikeFactor))
bool adxOK = (not useADXFilter or (not na(adx) and adx <= maximumADX))

// ============================================================================
// SECTION 15: CONFIRMED H1 BIAS
// ============================================================================
float h1EMA = request.security(syminfo.tickerid, "60", ta.ema(close, h1EMALength)[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
float h1Close = request.security(syminfo.tickerid, "60", close[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
bool longBiasOK = (not useH1EMABias or (not na(h1EMA) and not na(h1Close) and h1Close > h1EMA))
bool shortBiasOK = (not useH1EMABias or (not na(h1EMA) and not na(h1Close) and h1Close < h1EMA))

// ============================================================================
// SECTION 16: FAILURE SWING STATES
// ============================================================================
//
// 0 = WAIT FOR EXTREME
// 1 = WAIT FOR RECOVERY
// 2 = TRACK REACTION HIGH / LOW
// 3 = WAIT FOR RSI BREAK
//
// ============================================================================
var int bullStage = 0
var int bearStage = 0
var int bullStartBar = na
var int bearStartBar = na
var float bullReactionHigh = na
var float bearReactionLow = na
var int bullExtremeCount = 0
var int bearExtremeCount = 0
var int bullPullbackCount = 0
var int bearPullbackCount = 0
var int bullBreakCount = 0
var int bearBreakCount = 0
var int lastProcessedBar = na
bool bullRSIBreak = false
bool bearRSIBreak = false
bool processState = (barstate.isconfirmed and (na(lastProcessedBar) or lastProcessedBar != bar_index))

// ============================================================================
// SECTION 17: PRICE CONFIRMATION QUEUE
// ============================================================================
var bool pendingLong = false
var bool pendingShort = false
var int pendingLongBar = na
var int pendingShortBar = na
if processState
    lastProcessedBar := bar_index
    if newTradingDay
        bullStage := 0
        bearStage := 0
        bullStartBar := na
        bearStartBar := na
        bullReactionHigh := na
        bearReactionLow := na
        pendingLong := false
        pendingShort := false
        pendingLongBar := na
        pendingShortBar := na

    // Expire old RSI patterns.
    if bullStage > 0 and not na(bullStartBar)
        if bar_index - bullStartBar > maximumSetupBars
            bullStage := 0
            bullStartBar := na
            bullReactionHigh := na
    if bearStage > 0 and not na(bearStartBar)
        if bar_index - bearStartBar > maximumSetupBars
            bearStage := 0
            bearStartBar := na
            bearReactionLow := na

    // Expire price confirmation windows.
    if pendingLong and not na(pendingLongBar)
        if bar_index - pendingLongBar > priceConfirmationBars
            pendingLong := false
            pendingLongBar := na
    if pendingShort and not na(pendingShortBar)
        if bar_index - pendingShortBar > priceConfirmationBars
            pendingShort := false
            pendingShortBar := na

    // ================================================================
    // BULLISH FAILURE SWING
    // ================================================================
    if bullStage == 0
        if rsi < oversoldLevel
            bullStage := 1
            bullStartBar := bar_index
            bullExtremeCount += 1
    else if bullStage == 1
        if rsi > oversoldLevel
            bullStage := 2
            bullReactionHigh := rsi
    else if bullStage == 2
        if rsi <= oversoldLevel
            bullStage := 1
            bullStartBar := bar_index
            bullReactionHigh := na
        else
            if rsi >= bullReactionHigh
                bullReactionHigh := rsi
            else if bullReactionHigh - rsi >= minimumPullbackRSI
                bullStage := 3
                bullPullbackCount += 1
    else if bullStage == 3
        if rsi <= oversoldLevel
            bullStage := 1
            bullStartBar := bar_index
            bullReactionHigh := na
        else if rsi > bullReactionHigh + breakoutBufferRSI
            bullRSIBreak := true
            bullBreakCount += 1
            bullStage := 0
            bullStartBar := na
            bullReactionHigh := na

    // ================================================================
    // BEARISH FAILURE SWING
    // ================================================================
    if bearStage == 0
        if rsi > overboughtLevel
            bearStage := 1
            bearStartBar := bar_index
            bearExtremeCount += 1
    else if bearStage == 1
        if rsi < overboughtLevel
            bearStage := 2
            bearReactionLow := rsi
    else if bearStage == 2
        if rsi >= overboughtLevel
            bearStage := 1
            bearStartBar := bar_index
            bearReactionLow := na
        else
            if rsi <= bearReactionLow
                bearReactionLow := rsi
            else if rsi - bearReactionLow >= minimumPullbackRSI
                bearStage := 3
                bearPullbackCount += 1
    else if bearStage == 3
        if rsi >= overboughtLevel
            bearStage := 1
            bearStartBar := bar_index
            bearReactionLow := na
        else if rsi < bearReactionLow - breakoutBufferRSI
            bearRSIBreak := true
            bearBreakCount += 1
            bearStage := 0
            bearStartBar := na
            bearReactionLow := na

    // ================================================================
    // REGISTER COMPLETED RSI SIGNALS
    // ================================================================
    if bullRSIBreak
        pendingLong := true
        pendingLongBar := bar_index
        pendingShort := false
        pendingShortBar := na
    if bearRSIBreak
        pendingShort := true
        pendingShortBar := bar_index
        pendingLong := false
        pendingLongBar := na

// ============================================================================
// SECTION 18: PRICE ACTION CONFIRMATION
// ============================================================================
bool longCandleOK = (not requireCandleDirection or close > open)
bool shortCandleOK = (not requireCandleDirection or close < open)
bool longBreakOK = (not requirePriceBreak or close > high[1])
bool shortBreakOK = (not requirePriceBreak or close < low[1])
bool longEMAOK = (not useEMAReclaim or close > ema)
bool shortEMAOK = (not useEMAReclaim or close < ema)
bool longPriceConfirmed = (longCandleOK and longBreakOK and longEMAOK)
bool shortPriceConfirmed = (shortCandleOK and shortBreakOK and shortEMAOK)

// ============================================================================
// SECTION 19: RAW SIGNALS
// ============================================================================
bool rawLongSignal = (pendingLong and longPriceConfirmed and volumeOK and adxOK and longBiasOK)
bool rawShortSignal = (pendingShort and shortPriceConfirmed and volumeOK and adxOK and shortBiasOK)

// ============================================================================
// SECTION 20: POSITION STATE
// ============================================================================
bool positionFlat = (strategy.position_size == 0)
bool positionLong = (strategy.position_size > 0)
bool positionShort = (strategy.position_size < 0)
bool positionJustClosed = (positionFlat and strategy.position_size[1] != 0)

// ============================================================================
// SECTION 21: COOLDOWN CONTROL
// ============================================================================
var int lastExitBar = na
if positionJustClosed
    lastExitBar := bar_index
bool cooldownOK = (na(lastExitBar) or bar_index - lastExitBar > cooldownBars)

// ============================================================================
// SECTION 22: CAN TRADE
// ============================================================================
bool canTrade = (positionFlat and tradesToday < maximumTradesPerDay and cooldownOK and sessionOK and currentCloseMinute < sessionEndTotal and barstate.isconfirmed)
bool ambiguousSignal = (rawLongSignal and rawShortSignal)
var int lastEntryBar = na
bool newEntryBar = (na(lastEntryBar) or bar_index != lastEntryBar)
bool finalLongSignal = (canTrade and newEntryBar and allowLong and rawLongSignal and not ambiguousSignal)
bool finalShortSignal = (canTrade and newEntryBar and allowShort and rawShortSignal and not ambiguousSignal)

// ============================================================================
// SECTION 23: ENTRY COUNTERS
// ============================================================================
var int longSignalCount = 0
var int shortSignalCount = 0
var int longEntryCount = 0
var int shortEntryCount = 0
if processState
    if rawLongSignal
        longSignalCount += 1
    if rawShortSignal
        shortSignalCount += 1

// ============================================================================
// SECTION 24: LONG ENTRY
// ============================================================================
if finalLongSignal
    strategy.entry("Long", strategy.long, comment="RSI Failure Swing V2 Long", alert_message="🟢 VÀO VỊ THẾ LONG (CNPS74 RSI Failure Swing V2)\\n🎯 Giá vào: " + str.tostring(close, format.mintick) + "\\n🛑 Cắt lỗ (SL): " + str.tostring(close - stopLossPoints, format.mintick) + "\\n💰 Chốt lời (TP): " + str.tostring(close + takeProfitPoints, format.mintick))
    tradesToday += 1
    longEntryCount += 1
    lastEntryBar := bar_index
    pendingLong := false
    pendingLongBar := na

// ============================================================================
// SECTION 25: SHORT ENTRY
// ============================================================================
if finalShortSignal
    strategy.entry("Short", strategy.short, comment="RSI Failure Swing V2 Short", alert_message="🔴 VÀO VỊ THẾ SHORT (CNPS74 RSI Failure Swing V2)\\n🎯 Giá vào: " + str.tostring(close, format.mintick) + "\\n🛑 Cắt lỗ (SL): " + str.tostring(close + stopLossPoints, format.mintick) + "\\n💰 Chốt lời (TP): " + str.tostring(close - takeProfitPoints, format.mintick))
    tradesToday += 1
    shortEntryCount += 1
    lastEntryBar := bar_index
    pendingShort := false
    pendingShortBar := na

// ============================================================================
// SECTION 26: ACTIVE RISK LEVELS
// ============================================================================
var float activeLongSL = na
var float activeLongTP = na
var float activeShortSL = na
var float activeShortTP = na

// ============================================================================
// SECTION 27: LONG SL / TP
// ============================================================================
if positionLong
    float entryPrice = strategy.position_avg_price
    activeLongSL := entryPrice - stopLossPoints
    activeLongTP := entryPrice + takeProfitPoints
    strategy.exit("Long Exit", from_entry="Long", stop=activeLongSL, limit=activeLongTP, comment_profit="TP Long", comment_loss="SL Long", alert_profit="💰 CHỐT LỜI LONG (TP HIT)\\n🎯 Giá chốt: " + str.tostring(activeLongTP, format.mintick), alert_loss="🛑 CẮT LỖ LONG (SL HIT)\\n🎯 Giá cắt: " + str.tostring(activeLongSL, format.mintick), disable_alert=disableSLTPAlerts)

// ============================================================================
// SECTION 28: SHORT SL / TP
// ============================================================================
if positionShort
    float entryPrice = strategy.position_avg_price
    activeShortSL := entryPrice + stopLossPoints
    activeShortTP := entryPrice - takeProfitPoints
    strategy.exit("Short Exit", from_entry="Short", stop=activeShortSL, limit=activeShortTP, comment_profit="TP Short", comment_loss="SL Short", alert_profit="💰 CHỐT LỜI SHORT (TP HIT)\\n🎯 Giá chốt: " + str.tostring(activeShortTP, format.mintick), alert_loss="🛑 CẮT LỖ SHORT (SL HIT)\\n🎯 Giá cắt: " + str.tostring(activeShortSL, format.mintick), disable_alert=disableSLTPAlerts)

// ============================================================================
// SECTION 29: OPTIONAL TIME EXIT
// ============================================================================
int barsHeld = (strategy.opentrades > 0 ? bar_index - strategy.opentrades.entry_bar_index(0) : 0)
if useTimeExit and strategy.position_size != 0
    if barsHeld >= maximumHoldingBars
        strategy.close_all(immediately=true, comment="Time Exit", alert_message="⏱️ ĐÓNG VỊ THẾ HẾT THỜI GIAN GIỮ (Time Exit)\\n🎯 Giá đóng: " + str.tostring(close, format.mintick))

// ============================================================================
// SECTION 30: POSITION CLEANUP
// ============================================================================
if positionJustClosed
    activeLongSL := na
    activeLongTP := na
    activeShortSL := na
    activeShortTP := na

// ============================================================================
// SECTION 31: SESSION END
// ============================================================================
bool finalSessionBar = (currentMinute < sessionEndTotal and currentCloseMinute >= sessionEndTotal)
if finalSessionBar and strategy.position_size != 0
    strategy.close_all(immediately=true, comment="Session End", alert_message="⏰ ĐÓNG VỊ THẾ HẾT PHIÊN (Session End)\\n🎯 Giá đóng: " + str.tostring(close, format.mintick))

// ============================================================================
// SECTION 32: EMA DISPLAY
// ============================================================================
plot(showEMA ? ema : na, title="Confirmation EMA", color=color.orange, linewidth=2)

// ============================================================================
// SECTION 33: SL / TP DISPLAY
// ============================================================================
plot(showActiveSLTP and positionLong ? activeLongSL : na, title="Long SL", color=color.red, linewidth=2, style=plot.style_linebr)
plot(showActiveSLTP and positionLong ? activeLongTP : na, title="Long TP", color=color.green, linewidth=2, style=plot.style_linebr)
plot(showActiveSLTP and positionShort ? activeShortSL : na, title="Short SL", color=color.red, linewidth=2, style=plot.style_linebr)
plot(showActiveSLTP and positionShort ? activeShortTP : na, title="Short TP", color=color.green, linewidth=2, style=plot.style_linebr)

// ============================================================================
// SECTION 34: SIGNAL MARKERS
// ============================================================================
plotshape(showSignalMarkers and bullRSIBreak, title="RSI Bull Break", style=shape.circle, location=location.belowbar, color=color.aqua, size=size.tiny, text="RSI")
plotshape(showSignalMarkers and bearRSIBreak, title="RSI Bear Break", style=shape.circle, location=location.abovebar, color=color.orange, size=size.tiny, text="RSI")
plotshape(showSignalMarkers and rawLongSignal, title="Confirmed Long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, text="L")
plotshape(showSignalMarkers and rawShortSignal, title="Confirmed Short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, text="S")

// ============================================================================
// SECTION 35: RSI DATA WINDOW
// ============================================================================
plot(rsi, title="RSI Value", color=color.purple, display=display.data_window)

// ============================================================================
// SECTION 36: DIAGNOSTICS
// ============================================================================
var table diagnostics = table.new(position.top_right, 2, 19, border_width=1)
if showDiagnostics and barstate.islast
    string positionText = (positionLong ? "LONG" : positionShort ? "SHORT" : "FLAT")
    table.cell(diagnostics, 0, 0, "CNPS74 V2")
    table.cell(diagnostics, 1, 0, timeframe.period)
    table.cell(diagnostics, 0, 1, "RSI")
    table.cell(diagnostics, 1, 1, str.tostring(rsi, "#.##"))
    table.cell(diagnostics, 0, 2, "Bull Stage")
    table.cell(diagnostics, 1, 2, str.tostring(bullStage))
    table.cell(diagnostics, 0, 3, "Bear Stage")
    table.cell(diagnostics, 1, 3, str.tostring(bearStage))
    table.cell(diagnostics, 0, 4, "Bull Extremes")
    table.cell(diagnostics, 1, 4, str.tostring(bullExtremeCount))
    table.cell(diagnostics, 0, 5, "Bear Extremes")
    table.cell(diagnostics, 1, 5, str.tostring(bearExtremeCount))
    table.cell(diagnostics, 0, 6, "Bull Pullbacks")
    table.cell(diagnostics, 1, 6, str.tostring(bullPullbackCount))
    table.cell(diagnostics, 0, 7, "Bear Pullbacks")
    table.cell(diagnostics, 1, 7, str.tostring(bearPullbackCount))
    table.cell(diagnostics, 0, 8, "Bull RSI Breaks")
    table.cell(diagnostics, 1, 8, str.tostring(bullBreakCount))
    table.cell(diagnostics, 0, 9, "Bear RSI Breaks")
    table.cell(diagnostics, 1, 9, str.tostring(bearBreakCount))
    table.cell(diagnostics, 0, 10, "Pending Long")
    table.cell(diagnostics, 1, 10, pendingLong ? "YES" : "NO")
    table.cell(diagnostics, 0, 11, "Pending Short")
    table.cell(diagnostics, 1, 11, pendingShort ? "YES" : "NO")
    table.cell(diagnostics, 0, 12, "ADX")
    table.cell(diagnostics, 1, 12, str.tostring(adx, "#.##"))
    table.cell(diagnostics, 0, 13, "ADX Filter OK")
    table.cell(diagnostics, 1, 13, adxOK ? "YES" : "NO")
    table.cell(diagnostics, 0, 14, "Long Signals")
    table.cell(diagnostics, 1, 14, str.tostring(longSignalCount))
    table.cell(diagnostics, 0, 15, "Short Signals")
    table.cell(diagnostics, 1, 15, str.tostring(shortSignalCount))
    table.cell(diagnostics, 0, 16, "Long Entries")
    table.cell(diagnostics, 1, 16, str.tostring(longEntryCount))
    table.cell(diagnostics, 0, 17, "Short Entries")
    table.cell(diagnostics, 1, 17, str.tostring(shortEntryCount))
    table.cell(diagnostics, 0, 18, "Trades Today")
    table.cell(diagnostics, 1, 18, str.tostring(tradesToday) + " / " + str.tostring(maximumTradesPerDay))

2. Những khái niệm kỹ thuật cốt lõi trong CNPS74

2.1. Máy trạng thái RSI Failure Swing 4 giai đoạn (bullStage / bearStage)

Khác với tín hiệu giao cắt RSI truyền thống, CNPS74 sử dụng biến trạng thái bullStage (cho chiều Long) và bearStage (cho chiều Short) chạy từ 0 đến 3 trên các nến đã đóng cửa (barstate.isconfirmed):

  • Stage 0 (Wait for Extreme): Chờ rsi < 30 (Bullish) hoặc rsi > 70 (Bearish). Khi xảy ra, ghi nhận mốc nến bắt đầu (bullStartBar / bearStartBar) và chuyển sang Stage 1.
  • Stage 1 (Wait for Recovery): Chờ RSI thoát khỏi vùng cực trị (rsi > 30 với Bullish, rsi < 70 với Bearish). Khi vượt qua, ghi nhận điểm phản ứng đầu tiên (bullReactionHigh hoặc bearReactionLow) và chuyển sang Stage 2.
  • Stage 2 (Track Reaction High/Low): Cập nhật liên tục đỉnh phản ứng bullReactionHigh (nếu RSI tiếp tục tăng) hoặc đáy phản ứng bearReactionLow (nếu RSI tiếp tục giảm). Nếu RSI hồi lại đủ biên độ tối thiểu (bullReactionHigh - rsi >= 5.0 hoặc rsi - bearReactionLow >= 5.0) mà không rơi ngược lại vùng quá bán/quá mua, bot chuyển sang Stage 3.
  • Stage 3 (Wait for RSI Break): Chờ RSI bứt phá qua điểm phản ứng kèm vùng đệm: rsi > bullReactionHigh + 0.5 (tạo bullRSIBreak) hoặc rsi < bearReactionLow - 0.5 (tạo bearRSIBreak). Nếu trong quá trình Stage 2 hoặc 3 mà RSI quay lại vùng cực trị ban đầu, máy trạng thái tự động reset về Stage 1. Ngoài ra, nếu mẫu hình kéo dài quá maximumSetupBars (25 nến) kể từ lúc bắt đầu, toàn bộ cấu trúc sẽ bị hủy về Stage 0.

2.2. Hàng chờ xác nhận giá (Price Confirmation Queue)

Khi bullRSIBreak hoặc bearRSIBreak kích hoạt, bot chưa vào lệnh ngay mà bật cờ pendingLong = true hoặc pendingShort = true (đồng thời xóa cờ chiều ngược lại để tránh xung đột). Cửa sổ chờ này chỉ có hiệu lực trong priceConfirmationBars (mặc định 3 nến). Trong khoảng thời gian này, giá phải thỏa mãn đồng thời:

  • Hướng nến (requireCandleDirection): close > open (Long) hoặc close < open (Short).
  • Phá vỡ nến trước (requirePriceBreak): close > high[1] (Long) hoặc close < low[1] (Short).
  • EMA Reclaim (useEMAReclaim - tùy chọn): close > ema (Long) hoặc close < ema (Short) với EMA 20.

2.3. Bộ lọc ADX Regime, Volume Spike và H1 EMA Bias

Để lọc các giai đoạn thị trường có xu hướng quá mạnh (dễ làm thất bại các lệnh bắt đảo chiều) hoặc thiếu thanh khoản, code cung cấp 3 bộ lọc tùy chọn:

  • ADX Filter (useADXFilter): Sử dụng ta.dmi(14, 14) và chỉ cho phép giao dịch khi adx <= 30.0, tránh vào lệnh ngược xu hướng khi thị trường đang có trend mạnh.
  • Volume Filter (requireVolumeSpike): Tính trung bình khối lượng ta.sma(volume, 20) và yêu cầu volume >= averageVolume * 1.2.
  • Confirmed H1 Bias (useH1EMABias): Lấy dữ liệu nến H1 đã đóng cửa (close[1] và ta.ema(close, 50)[1] với lookahead=barmerge.lookahead_on), đảm bảo không bị repaint khi backtest và chỉ cho phép Long khi H1 close > EMA 50 (Short khi close < EMA 50).

3. Nguyên lý hoạt động của CNPS74

Toàn bộ quy trình vận hành của Bot CNPS74 diễn ra tuần tự trên mỗi nến đã đóng cửa (barstate.isconfirmed) qua 5 bước:

  1. Khởi tạo ngày giao dịch mới (newTradingDay): Dựa theo múi giờ Asia/Ho_Chi_Minh, khi sang ngày mới, bot reset bộ đếm tradesToday := 0, đưa toàn bộ máy trạng thái (bullStage, bearStage) về 0 và xóa sạch hàng chờ pendingLong, pendingShort.
  2. Cập nhật chỉ báo & Máy trạng thái RSI: Tính toán rsi, ema, adx, averageVolume và dữ liệu H1. Kiểm tra hết hạn mẫu hình (maximumSetupBars = 25) hoặc hết hạn hàng chờ (priceConfirmationBars = 3), sau đó cập nhật tiến trình Failure Swing để phát hiện bullRSIBreak / bearRSIBreak.
  3. Xác nhận Price Action & Bộ lọc (rawLongSignal / rawShortSignal): Khi đang có cờ pendingLong (hoặc pendingShort), bot kiểm tra điều kiện nến tăng/giảm, phá vỡ đỉnh/đáy nến trước, EMA (nếu bật) cùng bộ lọc Volume, ADX và H1 Bias.
  4. Kiểm tra điều kiện kiểm soát & Gửi lệnh (canTrade): Đảm bảo tài khoản đang không có vị thế (positionFlat), chưa vượt quá maximumTradesPerDay (2 lệnh/ngày), đã qua thời gian nghỉ cooldownBars (5 nến), nằm trong giờ giao dịch hợp lệ và không có tín hiệu hai chiều cùng lúc (not ambiguousSignal). Nếu đạt, bot gửi lệnh strategy.entry, tăng tradesToday và xóa cờ chờ.
  5. Quản trị vị thế & Đóng lệnh cuối phiên: Ngay khi khớp lệnh, strategy.exit thiết lập SL (5 điểm) và TP (10 điểm) tính từ strategy.position_avg_price. Nếu bật useTimeExit và số nến giữ barsHeld >= 20, hoặc khi chạm mốc 14:45 (finalSessionBar), bot tự động gọi strategy.close_all(immediately=true).

4. Điều kiện vào lệnh Long và Short của CNPS74

4.1. Điều kiện vào lệnh Long

Lệnh Long (finalLongSignal) được thực thi khi tất cả điều kiện sau đồng thời thỏa mãn:

  1. allowLong là true (tradeDirection chọn "Long" hoặc "Both").
  2. RSI đã hoàn thành chuỗi Bullish Failure Swing (bullStage đi qua 0 -> 1 -> 2 -> 3 với rsi < 30, hồi lên > 30, giảm tối thiểu 5.0 điểm RSI mà không chạm lại <= 30, rồi bứt phá lên trên bullReactionHigh + 0.5) trong vòng tối đa 25 nến.
  3. Đang trong cửa sổ chờ pendingLong == true (tối đa 3 nến kể từ lúc bullRSIBreak).
  4. Xác nhận giá (longPriceConfirmed):
    • Nến hiện tại là nến tăng: close > open (nếu requireCandleDirection = true).
    • Giá đóng cửa vượt đỉnh nến trước: close > high[1] (nếu requirePriceBreak = true).
    • Giá đóng cửa trên EMA 20: close > ema (nếu bật useEMAReclaim).
  5. Thỏa mãn các bộ lọc tùy chọn (nếu được bật): volumeOK, adxOK (adx <= 30.0), và longBiasOK (H1 close[1] > H1 EMA 50).
  6. Thỏa mãn điều kiện kiểm soát chung canTrade, newEntryBar và not ambiguousSignal.

4.2. Điều kiện vào lệnh Short

Lệnh Short (finalShortSignal) hoạt động đối xứng ngược lại hoàn toàn:

  1. allowShort là true (tradeDirection chọn "Short" hoặc "Both").
  2. RSI đã hoàn thành chuỗi Bearish Failure Swing (rsi > 70, giảm xuống < 70, hồi tăng tối thiểu 5.0 điểm RSI mà không chạm lại >= 70, rồi thủng xuống dưới bearReactionLow - 0.5) trong vòng tối đa 25 nến.
  3. Đang trong cửa sổ chờ pendingShort == true (tối đa 3 nến kể từ lúc bearRSIBreak).
  4. Xác nhận giá (shortPriceConfirmed):
    • Nến hiện tại là nến giảm: close < open (nếu requireCandleDirection = true).
    • Giá đóng cửa thủng đáy nến trước: close < low[1] (nếu requirePriceBreak = true).
    • Giá đóng cửa dưới EMA 20: close < ema (nếu bật useEMAReclaim).
  5. Thỏa mãn các bộ lọc tùy chọn: volumeOK, adxOK, và shortBiasOK (H1 close[1] < H1 EMA 50).
  6. Thỏa mãn điều kiện kiểm soát chung canTrade, newEntryBar và not ambiguousSignal.

4.3. Điều kiện kiểm soát giao dịch chung

Biến canTrade đóng vai trò chốt chặn an toàn trước khi gửi bất kỳ lệnh nào:

  • Không nhồi lệnh (positionFlat): strategy.position_size == 0 (và pyramiding=0).
  • Giới hạn lệnh/ngày: tradesToday < maximumTradesPerDay (mặc định tối đa 2 lệnh/ngày).
  • Thời gian nghỉ sau thoát lệnh (cooldownOK): bar_index - lastExitBar > cooldownBars (mặc định phải đợi qua 5 nến sau khi vị thế trước đóng lại).
  • Khung giờ giao dịch (sessionOK & currentCloseMinute < sessionEndTotal): Nếu bật useSessionFilter, chỉ nhận lệnh khi nến mở từ 09:15 trở đi và đóng trước hoặc bằng 14:15. Trong mọi trường hợp, nến vào lệnh phải đóng trước giờ Force Close 14:45.
  • Xác nhận đóng nến (barstate.isconfirmed): Chỉ xử lý tín hiệu khi nến đã đóng hoàn toàn, tránh nhiễu tín hiệu giả giữa nến.

5. Quản trị Stop Loss, Take Profit và Thoát lệnh

5.1. Cơ chế Stop Loss và bộ lọc Risk

CNPS74 áp dụng cơ chế cắt lỗ cố định theo điểm số trực tiếp từ giá khớp lệnh trung bình (strategy.position_avg_price):

  • Với vị thế Long: activeLongSL = entryPrice - stopLossPoints (mặc định trừ 5.0 điểm).
  • Với vị thế Short: activeShortSL = entryPrice + stopLossPoints (mặc định cộng 5.0 điểm).
  • Lưu ý trong code không sử dụng bộ lọc giới hạn Min–Max Risk theo ATR hay kích thước nến, mà dùng khoảng dừng lỗ cố định stopLossPoints để kiểm soát chặt mức lỗ tối đa trên mỗi hợp đồng VN30F1M.

5.2. Cơ chế Take Profit, Time Exit và Session End

  • Take Profit cố định:
    • Long: activeLongTP = entryPrice + takeProfitPoints (mặc định cộng 10.0 điểm).
    • Short: activeShortTP = entryPrice - takeProfitPoints (mặc định trừ 10.0 điểm).
    • Tỷ lệ Risk:Reward mặc định đạt 1:2, phù hợp với các nhịp hồi kỹ thuật sau Failure Swing.
  • Break Even & Trailing: Chiến lược không sử dụng cơ chế dời hòa vốn (Break Even) hay Trailing Stop nhằm giữ nguyên mục tiêu lợi nhuận 10 điểm khi giá bật hồi.
  • Thoát lệnh theo thời gian (useTimeExit): Nếu người dùng bật tùy chọn này, khi số nến nắm giữ barsHeld >= maximumHoldingBars (mặc định 20 nến), bot sẽ chủ động đóng toàn bộ vị thế bằng strategy.close_all(immediately=true) với ghi chú "Time Exit".
  • Đóng lệnh cuối phiên (finalSessionBar): Khi nến chuyển giao qua mốc 14:45 (currentMinute < 14:45 và currentCloseMinute >= 14:45), nếu vẫn còn vị thế mở, bot lập tức tất toán toàn bộ bằng strategy.close_all(immediately=true) với ghi chú "Session End" để tránh rủi ro qua đêm (overnight gap).

5.3. Bảng tổng hợp cơ chế bảo vệ vị thế

Cơ chế thoát lệnhĐiều kiện kích hoạtHành động thực thiTrạng thái mặc định
Stop Loss (SL)Giá chạm entryPrice ± 5.0 điểmThoát lệnh qua strategy.exit (SL Long / SL Short)Bật (5.0 điểm)
Take Profit (TP)Giá chạm entryPrice ± 10.0 điểmChốt lời qua strategy.exit (TP Long / TP Short)Bật (10.0 điểm)
Time ExitbarsHeld >= maximumHoldingBars (20 nến)Đóng ngay bằng strategy.close_all (Time Exit)Tắt (false)
Session EndNến đóng chạm/vượt 14:45 (giờ VN)Đóng ngay bằng strategy.close_all (Session End)Luôn bật

6. Hướng dẫn cài đặt và đọc bảng Diagnostics trên TradingView

Các bước cài đặt

  1. Mở biểu đồ hợp đồng phái sinh VN30F1M trên TradingView (nên chọn khung thời gian ngắn như M5 hoặc M15 để tối ưu số lượng mẫu hình trong ngày).
  2. Nhấp vào tab Pine Editor ở thanh công cụ phía dưới màn hình.
  3. Xóa toàn bộ đoạn mã mẫu có sẵn, sau đó sao chép toàn bộ mã nguồn Pine Script v6 của CNPS74 ở Mục 1 và dán vào trình soạn thảo.
  4. Nhấn Save (Lưu) để lưu chiến lược vào tài khoản cá nhân, sau đó nhấn Add to chart (Thêm vào biểu đồ).
  5. Nhấp vào biểu tượng bánh răng (Settings) bên cạnh tên chiến lược CNPS74 RSI FS V2 để bật tradeDirection = "Both" nếu bạn muốn giao dịch cả 2 chiều Long/Short (mặc định code đang để "Long"), hoặc bật các bộ lọc ADX, Volume, H1 EMA và showDiagnostics.

Cách đọc bảng chẩn đoán (Diagnostics Table)

Khi bật tùy chọn Show Diagnostics? (showDiagnostics = true), bot sẽ hiển thị bảng table.new gồm 19 dòng ở góc trên bên phải biểu đồ:

Dòng hiển thịÝ nghĩa thực tế
CNPS74 V2 / TimeframeTên phiên bản bot và khung thời gian biểu đồ đang chạy
RSIGiá trị RSI hiện tại
Bull Stage / Bear StageGiai đoạn hiện tại (0, 1, 2, 3) của máy trạng thái Failure Swing chiều tăng và giảm
Bull / Bear ExtremesTổng số lần RSI đi vào vùng quá bán (< 30) / quá mua (> 70)
Bull / Bear PullbacksTổng số lần RSI hoàn thành nhịp kéo ngược hợp lệ sang Stage 3
Bull / Bear RSI BreaksTổng số lần RSI phá vỡ điểm phản ứng thành công
Pending Long / Pending ShortTrạng thái YES/NO cho biết bot có đang trong cửa sổ chờ xác nhận nến hay không
ADX / ADX Filter OKGiá trị ADX hiện tại và trạng thái có đạt điều kiện lọc adx <= 30.0 hay không
Long / Short SignalsTổng số tín hiệu thô (rawLongSignal / rawShortSignal) xuất hiện
Long / Short EntriesTổng số lệnh thực tế đã vào (longEntryCount / shortEntryCount)
Trades TodaySố lệnh đã giao dịch trong ngày trên tổng giới hạn (tradesToday / maximumTradesPerDay)

7. Cách thiết lập cảnh báo tín hiệu giao dịch (Alert)

Để nhận thông báo tín hiệu giao dịch tự động qua ứng dụng TradingView, Telegram hoặc Webhook, bạn thực hiện thiết lập Alert như sau:

  1. Nhấn vào biểu tượng Alert (hình đồng hồ báo thức) hoặc nhấn tổ hợp phím Alt + A.
  2. Ở mục Condition, chọn đúng tên chiến lược CNPS74 RSI FAILURE SWING V2.
  3. Ở ô Message, xóa toàn bộ nội dung mặc định và điền duy nhất biến: {{strategy.order.alert_message}}
  4. Nhấn Create để kích hoạt cảnh báo. Nếu không muốn nhận thông báo khi chạm SL/TP, bạn có thể tích chọn Disable SL / TP Alerts? trong phần cài đặt bot.

Bảng thông điệp Alert của CNPS74

Loại sự kiệnHành động trong codeNội dung thông điệp (alert_message / alert_profit / alert_loss)
Vào lệnh Longstrategy.entry("Long", ...)🟢 VÀO VỊ THẾ LONG (CNPS74 RSI Failure Swing V2) kèm Giá vào, SL (close - 5), TP (close + 10)
Vào lệnh Shortstrategy.entry("Short", ...)🔴 VÀO VỊ THẾ SHORT (CNPS74 RSI Failure Swing V2) kèm Giá vào, SL (close + 5), TP (close - 10)
Chốt lời (TP)strategy.exit(..., alert_profit=...)💰 CHỐT LỜI LONG (TP HIT) hoặc 💰 CHỐT LỜI SHORT (TP HIT) kèm Giá chốt
Cắt lỗ (SL)strategy.exit(..., alert_loss=...)🛑 CẮT LỖ LONG (SL HIT) hoặc 🛑 CẮT LỖ SHORT (SL HIT) kèm Giá cắt
Hết thời gian giữstrategy.close_all(..., comment="Time Exit")⏱️ ĐÓNG VỊ THẾ HẾT THỜI GIAN GIỮ (Time Exit) kèm Giá đóng
Hết phiên (14:45)strategy.close_all(..., comment="Session End")⏰ ĐÓNG VỊ THẾ HẾT PHIÊN (Session End) kèm Giá đóng

Kết luận

CNPS74 RSI Failure Swing V2 là một hệ thống giao dịch đảo chiều bài bản cho VN30F1M, khắc phục triệt để nhược điểm vào lệnh sớm của chỉ báo RSI thông thường nhờ cấu trúc máy trạng thái 4 giai đoạn và hàng chờ xác nhận hành động giá. Bot phát huy hiệu quả cao nhất trong các phiên thị trường đi ngang (sideway) hoặc biến động có nhịp hồi rõ ràng, nơi các bộ lọc ADX và H1 EMA Bias giúp tránh được các pha bứt phá xu hướng mạnh.

Bạn có thể tham khảo thêm các chiến lược giao dịch phái sinh khác trên hệ thống như Bot CNPS50 - Trend Analysis V2 và Bot CNPS49 - Daily Open để đa dạng hóa danh mục chiến lược của mình.

Thông tin chỉ mang tính tham khảo, không phải khuyến nghị đầu tư. Kết quả kiểm thử quá khứ không đảm bảo lợi nhuận trong tương lai.

Thông tin trong bài chỉ mang tính tham khảo, không phải khuyến nghị mua bán. Giao dịch phái sinh có rủi ro cao do sử dụng đòn bẩy; nhà đầu tư tự chịu trách nhiệm với quyết định của mình.

Đinh Mạnh Đạt

Nhà nghiên cứu định lượng, chuyên sâu về dữ liệu Open Interest và quản trị vị thế.

Bản tin phái sinh mỗi phiên
Nhận bản tin mỗi phiên + Dự báo Nhịp đập phái sinh

Giao dịch & cuộc sống

Xem tất cả →
Cộng đồng