BeiDou YaoGuang
- 专家
- 版本: 3.11
- 激活: 5
**Core Strategy**
Beidou·Yaoguang is a trend-following Expert Advisor for MetaTrader 4, built on Parabolic SAR flips. It goes long when SAR flips from bearish to bullish, and short when SAR flips from bullish to bearish. Signals are confirmed on the previous closed bar to filter noise. Entry uses the K0 bar’s high (for longs) or low (for shorts) plus/minus a configurable offset, placed as Buy Stop / Sell Stop pending orders. If price has already broken out, an optional market entry can be used. Opposite pending orders are automatically deleted when SAR flips again.
**Risk & Position Sizing**
Position size follows a nine-step calculation: equity/balance rounding → risk amount → stop-loss points → value per point → theoretical lot → step rounding → min/max checks. Equity or balance is rounded down to the highest digit when ≥100; values below 100 are used as-is. Risk per trade is configurable (default 1%), with a max lot cap for protection. Short stop-loss is set to SAR + spread, keeping long/short symmetry.
**Partial TP & Trailing SL**
Two-stage take profit is supported, with adjustable multipliers and lot percentages. Stop-loss trails SAR for longs, and SAR + spread for shorts. Stop-loss distance is validated before entry; invalid trades are skipped and logged.
**Martingale**
Optional martingale with a configurable multiplier (default 1.5). After consecutive losses, the next risk = base risk × 1.5ⁿ, capped at a user-defined maximum (default 20%). Any take-profit resets the martingale counter to zero. The counter is saved in MT4 global variables and survives EA restarts.
**Stop After All TP**
When all positions and pending orders are closed by take profit, trading pauses until the next day 00:00. The panel shows a live countdown. Trading resumes automatically after midnight.
**Session & Cooldown**
Configurable session filter with hour+minute precision, supporting overnight sessions. Optional cooldown after closing positions.
**Restart Takeover**
Four takeover scenarios handle EA restarts:
1. Pending order unfilled, SAR not flipped → keep pending order.
2. Pending order unfilled, SAR flipped → delete pending order.
3. Position open, SAR not flipped → keep position.
4. Position open, SAR flipped → close at market, update martingale based on P/L.
A profitable takeover close triggers the TP-pause; a losing close increments the martingale counter.
**Visual Panel**
A dark-themed Chinese panel shows SAR status, bid/ask, spread, min stop level, floating P/L, TP/SL amounts, cooldown, martingale status, and TP-pause countdown. Buttons include: Long Only / Both / Short Only / Wait direction switch, auto-trading toggle, one-click close (with confirmation), reset state, and manual BUY STOP / SELL STOP. Manual and auto trading are mutually exclusive.
**Order Management**
Magic number isolation (default 5454545). Order comments: “北斗摇光做多” / “北斗摇光做空”. Pending order expiry in hours (0 = never). Failed orders are retried automatically (default 60s timeout, 500ms interval). Partial fills are handled per batch.
**Compatibility**
MT4, 4/5-digit quotes, any symbol/timeframe. Recommended for trending instruments like EURUSD, XAUUSD, USOIL. All inputs are in Chinese with clear grouping. Logs cover order send/modify/delete, takeover, and retry.
**Compliance**
No profit guarantee. Test on demo first. Martingale increases risk; set risk cap and max lot carefully.
