Quanta Docs
·Tài liệu Quanta hoàn chỉnh cho Quant Studio
Bài họcrecipelesson/exit-management
Bài 5 — Quản lý thoát: trailing ATR stop
Dùng `get … when` (valuewhen) để neo điểm vào, trailing stop bằng ATR, `enter`/`close` Story.
quanta
strategy "Trail ATR" @regime "trending" @style "momentum, swing" @detail "Reclaim SMA50 rồi trailing stop theo ATR." params: k = 2.5 in [1.0..5.0] ma_len = 50 in [20..100] detect: c = market.close a = atr(market.high, market.low, c, 14) in_long = position.is_hold and position.is_long ma = sma(c, ma_len) long_setup = c crossover ma entry_close = get c when long_setup trail = entry_close - k * a act: when long_setup and not in_long: enter long with wnav 5pct tag "long entry" when in_long and c < trail: close long tag "trail stop" render: panel main: line ma as "MA" in orange line trail as "ATR trail" in gray dashed
get c when long_setuplà story củavaluewhen(long_setup, c)— neo giá lúc vào lệnh.enter long with wnav 5pct/close longthaybuy(weight:)/sell(all: true).
#intermediate#exit
Trợ lý Quanta"Học nhanh hơn, hiệu quả hơn cùng AI"
Xin chào! Tôi là trợ lý học ngôn ngữ Quanta. Hỏi tôi về cú pháp, hàm, hoặc cách viết một chiến lược cụ thể (ví dụ: "Làm sao để xác định đỉnh đáy để vẽ trendline?").