Hướng Dẫn Sử Dụng Bot CNPS74 - RSI Failure Swing V2 cho VN30F1M
TradingviewBot 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.

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
priceConfirmationBarsnế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:
- 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ạnmaximumSetupBars(25 nến). - Xác nhận Hành động Giá (Price Action Confirmation): Sau khi có tín hiệu
bullRSIBreakhoặcbearRSIBreak, 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). - 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). - 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:45giờ 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 |
|---|---|---|---|
| RSI | rsiLength | 14 | Chu kỳ tính chỉ báo RSI |
| RSI | oversoldLevel / overboughtLevel | 30 / 70 | Ngưỡng quá bán và quá mua |
| Failure Swing | minimumPullbackRSI | 5.0 | Biên độ hồi tối thiểu của RSI để xác nhận nhịp pullback |
| Failure Swing | maximumSetupBars | 25 | Số nến tối đa để hoàn thành một mẫu hình Failure Swing |
| Failure Swing | breakoutBufferRSI | 0.5 | Vùng đệm cộng thêm khi RSI phá vỡ điểm phản ứng |
| Price Confirmation | requirePriceBreak | true | Yêu cầu giá đóng cửa vượt high[1] (Long) hoặc thủng low[1] (Short) |
| Price Confirmation | requireCandleDirection | true | Yêu cầu nến xác nhận là nến tăng (close > open) hoặc giảm (close < open) |
| Price Confirmation | priceConfirmationBars | 3 | Số nến tối đa cho phép chờ xác nhận giá sau khi RSI Break |
| Price Confirmation | useEMAReclaim / emaLength | false / 20 | Tùy chọn yêu cầu giá đóng cửa trên/dưới đường EMA 20 |
| ADX | useADXFilter | false | Bật/tắt bộ lọc giới hạn ADX |
| ADX | diLength / adxSmoothing / maximumADX | 14 / 14 / 30.0 | Chu kỳ DMI/ADX và ngưỡng ADX tối đa cho phép vào lệnh |
| Volume | requireVolumeSpike | false | Bật/tắt điều kiện khối lượng đột biến |
| Volume | volumeAverageLength / volumeSpikeFactor | 20 / 1.2 | Chu kỳ SMA khối lượng và hệ số nhân đột biến |
| H1 Trend | useH1EMABias / h1EMALength | false / 50 | Lọc xu hướng theo nến H1 đã đóng cửa so với EMA 50 khung H1 |
| Risk Management | stopLossPoints / takeProfitPoints | 5.0 / 10.0 | Mức Cắt lỗ (5 điểm) và Chốt lời (10 điểm) cố định |
| Risk Management | useTimeExit / maximumHoldingBars | false / 20 | Tùy chọn đóng lệnh nếu giữ quá số nến tối đa |
| Trade Control | maximumTradesPerDay | 2 | Số lệnh tối đa được phép mở trong một ngày |
| Trade Control | tradeDirection | "Long" | Chiều giao dịch ("Long", "Short", "Both") |
| Trade Control | cooldownBars | 5 | Số nến nghỉ tối thiểu sau khi đóng vị thế trước |
| Session | useSessionFilter | false | Bật/tắt lọc khung giờ vào lệnh (09:15 – 14:15) |
| Session | sessionEndHour : sessionEndMinute | 14:45 | Giờ bắt buộc đóng toàn bộ vị thế cuối phiên (Asia/Ho_Chi_Minh) |
| Alerts & Display | disableSLTPAlerts / showDiagnostics | false / false | Tắ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ặcrsi > 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 > 30với Bullish,rsi < 70với Bearish). Khi vượt qua, ghi nhận điểm phản ứng đầu tiên (bullReactionHighhoặcbearReactionLow) 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 ứngbearReactionLow(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.0hoặcrsi - 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ạobullRSIBreak) hoặcrsi < bearReactionLow - 0.5(tạobearRSIBreak). 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ặcclose < open(Short). - Phá vỡ nến trước (
requirePriceBreak):close > high[1](Long) hoặcclose < low[1](Short). - EMA Reclaim (
useEMAReclaim- tùy chọn):close > ema(Long) hoặcclose < 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ụngta.dmi(14, 14)và chỉ cho phép giao dịch khiadx <= 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ượngta.sma(volume, 20)và yêu cầuvolume >= 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ớilookahead=barmerge.lookahead_on), đảm bảo không bị repaint khi backtest và chỉ cho phép Long khi H1close > EMA 50(Short khiclose < 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:
- 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ộ đếmtradesToday := 0, đưa toàn bộ máy trạng thái (bullStage,bearStage) về0và xóa sạch hàng chờpendingLong,pendingShort. - Cập nhật chỉ báo & Máy trạng thái RSI: Tính toán
rsi,ema,adx,averageVolumevà 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ệnbullRSIBreak/bearRSIBreak. - Xác nhận Price Action & Bộ lọc (
rawLongSignal/rawShortSignal): Khi đang có cờpendingLong(hoặcpendingShort), 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. - 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ệnhstrategy.entry, tăngtradesTodayvà xóa cờ chờ. - Quản trị vị thế & Đóng lệnh cuối phiên: Ngay khi khớp lệnh,
strategy.exitthiết lập SL (5 điểm) và TP (10 điểm) tính từstrategy.position_avg_price. Nếu bậtuseTimeExitvà số nến giữbarsHeld >= 20, hoặc khi chạm mốc14:45(finalSessionBar), bot tự động gọistrategy.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:
allowLonglàtrue(tradeDirectionchọn"Long"hoặc"Both").- RSI đã hoàn thành chuỗi Bullish Failure Swing (
bullStageđi qua0 -> 1 -> 2 -> 3vớirsi < 30, hồi lên> 30, giảm tối thiểu5.0điểm RSI mà không chạm lại<= 30, rồi bứt phá lên trênbullReactionHigh + 0.5) trong vòng tối đa25nến. - Đang trong cửa sổ chờ
pendingLong == true(tối đa3nến kể từ lúcbullRSIBreak). - Xác nhận giá (
longPriceConfirmed):- Nến hiện tại là nến tăng:
close > open(nếurequireCandleDirection = true). - Giá đóng cửa vượt đỉnh nến trước:
close > high[1](nếurequirePriceBreak = true). - Giá đóng cửa trên EMA 20:
close > ema(nếu bậtuseEMAReclaim).
- Nến hiện tại là nến tăng:
- 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(H1close[1] > H1 EMA 50). - Thỏa mãn điều kiện kiểm soát chung
canTrade,newEntryBarvà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:
allowShortlàtrue(tradeDirectionchọn"Short"hoặc"Both").- RSI đã hoàn thành chuỗi Bearish Failure Swing (
rsi > 70, giảm xuống< 70, hồi tăng tối thiểu5.0điểm RSI mà không chạm lại>= 70, rồi thủng xuống dướibearReactionLow - 0.5) trong vòng tối đa25nến. - Đang trong cửa sổ chờ
pendingShort == true(tối đa3nến kể từ lúcbearRSIBreak). - Xác nhận giá (
shortPriceConfirmed):- Nến hiện tại là nến giảm:
close < open(nếurequireCandleDirection = true). - Giá đóng cửa thủng đáy nến trước:
close < low[1](nếurequirePriceBreak = true). - Giá đóng cửa dưới EMA 20:
close < ema(nếu bậtuseEMAReclaim).
- Nến hiện tại là nến giảm:
- Thỏa mãn các bộ lọc tùy chọn:
volumeOK,adxOK, vàshortBiasOK(H1close[1] < H1 EMA 50). - Thỏa mãn điều kiện kiểm soát chung
canTrade,newEntryBarvà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 đa2lệnh/ngày). - Thời gian nghỉ sau thoát lệnh (
cooldownOK):bar_index - lastExitBar > cooldownBars(mặc định phải đợi qua5nến sau khi vị thế trước đóng lại). - Khung giờ giao dịch (
sessionOK¤tCloseMinute < sessionEndTotal): Nếu bậtuseSessionFilter, chỉ nhận lệnh khi nến mở từ09:15trở đi và đóng trước hoặc bằng14:15. Trong mọi trường hợp, nến vào lệnh phải đóng trước giờ Force Close14: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ộng5.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ộng10.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.
- Long:
- 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 định20nến), bot sẽ chủ động đóng toàn bộ vị thế bằngstrategy.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ốc14:45(currentMinute < 14:45và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ằngstrategy.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ạt | Hành động thực thi | Trạng thái mặc định |
|---|---|---|---|
| Stop Loss (SL) | Giá chạm entryPrice ± 5.0 điểm | Thoá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ểm | Chốt lời qua strategy.exit (TP Long / TP Short) | Bật (10.0 điểm) |
| Time Exit | barsHeld >= maximumHoldingBars (20 nến) | Đóng ngay bằng strategy.close_all (Time Exit) | Tắt (false) |
| Session End | Nế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
- 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).
- Nhấp vào tab Pine Editor ở thanh công cụ phía dưới màn hình.
- 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.
- 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 đồ).
- 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ậttradeDirection = "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 / Timeframe | Tên phiên bản bot và khung thời gian biểu đồ đang chạy |
| RSI | Giá trị RSI hiện tại |
| Bull Stage / Bear Stage | Giai đ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 Extremes | Tổng số lần RSI đi vào vùng quá bán (< 30) / quá mua (> 70) |
| Bull / Bear Pullbacks | Tổng số lần RSI hoàn thành nhịp kéo ngược hợp lệ sang Stage 3 |
| Bull / Bear RSI Breaks | Tổng số lần RSI phá vỡ điểm phản ứng thành công |
| Pending Long / Pending Short | Trạ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 OK | Giá 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 Signals | Tổng số tín hiệu thô (rawLongSignal / rawShortSignal) xuất hiện |
| Long / Short Entries | Tổng số lệnh thực tế đã vào (longEntryCount / shortEntryCount) |
| Trades Today | Số 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:
- 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. - Ở mục Condition, chọn đúng tên chiến lược CNPS74 RSI FAILURE SWING V2.
- Ở ô Message, xóa toàn bộ nội dung mặc định và điền duy nhất biến:
{{strategy.order.alert_message}} - 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ện | Hành động trong code | Nội dung thông điệp (alert_message / alert_profit / alert_loss) |
|---|---|---|
| Vào lệnh Long | strategy.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 Short | strategy.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.





