Candle x Env TPSL
- Experts
- Suriya Thammalungka
- Version: 1.1
- Activations: 5
Candle XENV TPSL Marti is an automated trading system designed to trade based on candle-structure breakouts combined with trend-filter logic.
The EA intelligently manages position sizing using dynamic lot sizing, martingale recovery, and adaptive risk control.
It is optimized for medium-term swing trading on H1 timeframes across major currency pairs.
The algorithm is built to avoid over-trading, reduce drawdown risk, and self-adjust to market volatility.
With improved margin protection and safe-lot logic, the EA can operate safely even on small accounts.
1. Candle Breakout Detection
The EA scans every new candle to detect momentum signals based on the following logic:
-
Strong bullish candle → Buy signal
-
Strong bearish candle → Sell signal
-
Candle structure is filtered by X-ENV conditions (custom volatility envelope)
Only when the candle body + wick satisfy the volatility envelope threshold does the EA allow a trade.
2. TPSL (Take Profit & Stop Loss Engine)
For every order, the EA automatically sets:
-
Fixed Take Profit
-
Fixed Stop Loss
-
Or dynamic TP/SL if selected by the user
The EA verifies stop-levels based on broker rules and adjusts them automatically to avoid errors.
3. Martingale Recovery System
If the previous trade hits a loss, the EA can activate a controlled martingale system:
-
Lot size increases by a configured multiplier
-
Only after a losing position
-
Only within safe-margin limits
This allows the system to recover loss cycles while still protecting the account using safe-lot and margin-checking logic.
4. SafeLot & Dynamic Risk Control
To avoid margin errors such as Error 134 (Not Enough Money), the EA includes:
-
SafeLot() function
-
Auto-lot reduction when margin is insufficient
-
Lot size normalized to broker LOTSTEP
-
Auto-skip trades when margin is too low
This ensures smooth backtesting and stable live trading across all brokers.
5. Consecutive Win/Loss Tracking
The EA records previous trade outcomes to determine:
-
If a martingale step should be triggered
-
Whether to reset lot size to initial volume
-
Whether a series of winning trades should stop trading to protect profit
This allows the EA to adapt dynamically based on recent performance.
6. Spread Filter (Optional)
Before opening a trade, the EA checks current spread:
-
If spread is too high → skip the trade
-
Prevents slippage and over-payment in volatile periods
7. Order Execution With Error Handling
All trades are executed through a custom OrderSend function with:
-
Retry logic
-
Error checking
-
Auto-correct lot size, SL, TP
-
Full protection against:
-
Error 130 (invalid stops)
-
Error 131 (invalid volume)
-
Error 134 (not enough money)
-
Error 4109 (trade not allowed)
-
This makes the EA extremely stable even on strict ECN brokers.
8. History-Aware Logic
The EA scans the account history to detect:
-
Last closed order
-
Direction
-
Profit or loss
-
Profit streaks
-
Loss streaks
This data directly influences new trade decisions and risk adjustments.
📌 Summary of Features| Feature | Description |
|---|---|
| Candle breakout entry | Entry based on strong candle momentum + XENV filter |
| Auto TP/SL | Fixed or dynamic SL/TP with broker-safe validation |
| Martingale mode | Controlled recovery using multiplier |
| SafeLot system | Reduces lot automatically when margin is insufficient |
| Spread filter | Avoids trading during bad conditions |
| Error handling | Protection against common MT4 OrderSend errors |
| History-based logic | Detects consecutive wins/losses |
| Magic Number separation | Supports multi-pair trading |
Candle XENV TPSL Marti is a stable and adaptive EA that focuses on candle-strength signals combined with a flexible risk-control system.
It is especially useful for traders who want:
-
Medium-risk martingale
-
Safe lot auto-adjustment
-
Strong error-free execution
-
Simple clear trading logic
-
Automatic trade management
The EA has excellent stability because it never forces trades when the account is too small — it automatically reduces the lot or skips unsafe positions.
This makes it suitable for both small accounts and medium-risk recovery strategies.

