FoxterAI
- Experts
- Serhii Shal
- Version: 2.0
- Activations: 5
FoxterAI — Grid Trading EA with ATR-Adaptive Step and Interactive Control Panel
FoxterAI is an automated grid trading robot for MetaTrader 4 built on an averaging grid strategy. The grid step is calculated from the ATR indicator rather than a fixed pip value: during high volatility orders are placed wider, during low volatility — closer together. The EA manages two independent series simultaneously — BUY and SELL.
Key Feature: Control Panel Fully Works Inside the Strategy Tester
The built-in interactive panel is fully functional in the Strategy Tester visual mode. During a backtest you can change key parameters without stopping the test: enable/disable trading, switch direction, change entry mode, activate Basket Mode, adjust profit target, enable the Level System, change grid limits — and immediately see the effect on results. This dramatically speeds up optimization.
Architecture
On every tick the EA executes: series update, DetectTrend(), CheckNewSeriesEntry(), ManagePositions() (breakeven, trailing, grid averaging, Take Profit), panel update.
Trend Detection
Custom ATR algorithm — average High-Low range over N completed bars on the selected timeframe. ATR is cached and recalculated only on new candle formation.
- TrendTimeframe — timeframe for trend detection (H1)
- TrendATR_Period — ATR period in bars (14)
SuperTrend
Built-in calculation without external indicators. Base = (High+Low)/2, Upper = Base + Mult x ATR, Lower = Base - Mult x ATR. Used as entry filter, averaging filter, and level source. SuperTrend line is drawn directly on the chart.
- SuperTrendTF — SuperTrend timeframe (H1)
- SuperTrendATRPeriod — ATR period (10)
- SuperTrendMultiplier — ATR multiplier (3.0)
- DrawSuperTrend — draw line on chart (true)
- SuperTrendBarsToDraw — bars to draw (300)
Entry Modes
Cycled through via the Entry Mode button on the panel. Four modes available:
- Trend only — enters in the direction of the trend
- Trend + Impulse (default) — additionally requires an impulse candle on M15 whose range exceeds the specified % of ATR
- Trend + Impulse + SuperTrend — maximum filtering: trend, impulse, and SuperTrend simultaneously
- Trend + SuperTrend — trend confirmed by SuperTrend, no impulse required
- EntryMode — entry mode (Trend + Impulse)
- ImpulseTimeframe — timeframe for impulse detection (M15)
- ImpulseATR_Period — ATR period for impulse (14)
- ImpulseMinPercent — minimum impulse size % of ATR (150)
- MinBarsBetweenSeries — bars between close and new entry (1)
Averaging Grid
Step = ATR(Grid_Timeframe, Grid_ATR_Period) x Grid_StepPercent / 100. Averaging triggers when all conditions are met: price moved one step from the last order, trend matches the series direction, minimum time interval passed, order count and total lot within limits.
- Grid_Timeframe — timeframe for step calculation (M15)
- Grid_ATR_Period — ATR period for step (14)
- Grid_StepPercent — grid step % of ATR (50)
- MartinCoeff — martingale multiplier (1.5)
- FirstLotMultiplier — first lot multiplier (1.0)
- MaxOrdersBuy / MaxOrdersSell — max orders per series (10)
- MaxTotalLot — max total lot per series (2.0)
- GridIntervalMinutes — minimum interval between averaging orders min (30)
- UseSTForAveraging — SuperTrend filter for averaging (false)
Advanced Grid and Martingale Modes
Expanding grid (UseExpandingGrid): each grid step is multiplied by GridStepMultiplier. Reduces averaging frequency during deep moves against the position.
Stepped martingale (UseSteppedMartin): divides the grid into three zones with different multipliers. Example: first 3 orders at 1.0, next 3 at 1.3, all subsequent at 1.6. Activates martingale only deep in the grid.
ATR-adaptive martingale (UseATRAdaptiveMartin): dynamically adjusts the multiplier based on current volatility. High volatility — minimum coefficient, low volatility — maximum. All three modes can be combined.
- UseExpandingGrid — expanding grid (false), GridStepMultiplier — step multiplier (1.3)
- UseSteppedMartin — stepped martingale (false)
- StepZone1Count / Coeff — zone 1: order count and multiplier (3 / 1.0)
- StepZone2Count / Coeff — zone 2 (3 / 1.3), StepZone3Coeff — zone 3 (1.6)
- UseATRAdaptiveMartin — ATR-adaptive martingale (false)
- ATRAdaptive_MinCoeff — min coefficient at high volatility (1.0)
- ATRAdaptive_MaxCoeff — max coefficient at low volatility (2.0)
Take Profit Modes
ATR-based TP: distance = ATR(TP_Timeframe, TP_ATR_Period) x TP_Percent / 100.
Deposit % TP: target = Balance x FirstTPDepositPercent / 100.
Individual TP: fixed TP per order in points (Basket Mode only, 0 = disabled).
Combined series TP: when 2+ orders exist, TP is recalculated from the weighted average open price. When IncludeCommissionSwap is enabled, accumulated commissions and swap are deducted.
- TP_Timeframe — ATR TP timeframe (M15), TP_ATR_Period — period (14)
- TP_Percent — TP size % of ATR (100)
- UseDepositPercentTP — deposit % TP (false)
- FirstTPDepositPercent — first order TP % of balance (0.5)
- IndividualTP_Points — individual TP in points (100, 0=disabled)
- IncludeCommissionSwap — include commission and swap in P&L (true)
- SlippagePercent — slippage compensation % of profit (0.1)
Basket
Combines BUY and SELL series for joint closing at a shared profit target. Three types:
- OFF — series managed independently
- Immediate — combined from the first order
- After N — combined after N averaging orders
Basket Mode: extended profit management — includes not only open but also already closed orders of the current grid. Allows accumulating profit from partial closings.
- BasketType — type: OFF / Immediate / After N (OFF)
- BasketProfitPercent — target profit % of balance (0.1)
- BasketAfterNOrders — combine after N averagings (5)
- UseBasketMode — Basket Mode (false)
Breakeven and Trailing
Breakeven activates when the series has 2+ orders. When price reaches the specified distance, SL is moved to the open price (or offset from it).
- UseBreakeven — enable breakeven (false)
- BreakevenActivatePoints — points to activate (100)
- BreakevenSL_Points — SL offset from open price (0 = at open price)
Trailing works only on the first order (no averaging). Disabled automatically when the second order appears. Distances are set as % of ATR.
- UseFirstOrderTrailing — enable trailing (false)
- TrailActivatePercent — activation threshold % of ATR (70)
- TrailDistancePercent — trailing distance % of ATR (50)
Level System
Optional module for anchoring grid logic to significant price levels. Enabled via the Levels button on the panel.
Three level sources (Source button):
- Round levels — levels at a fixed pip step (e.g. every 50 points). 21 levels around current price
- Daily High/Low — High/Low levels over N bars on two timeframes. Default: D1x1 + W1x1 = 4 levels
- SuperTrend TF — SuperTrend boundary on the LevelTF timeframe
Four operating modes (Mode button):
- Filter — levels displayed, no effect on trading
- TP at levels — TP is set at the nearest level in trade direction
- Entry only — first order opens only near a level (LevelEntryZone x ATR)
- Full — TP at levels + entry near level + grid step adapted to next level
- UseLevelAveraging — enable system (false), LevelSource — source: Round/D-HL/ST-TF
- RoundLevelStep — round level step points (50), LevelTF — timeframe for ST levels (H4)
- LevelHL_TF1/Count1 — D-HL pair 1 (D1 / 1), LevelHL_TF2/Count2 — pair 2 (W1 / 1)
- UseLevelTP — TP at levels (false), LevelTP_OffsetPips — TP offset from level points (5)
- UseLevelEntry — entry near level only (false), LevelEntryZone — entry zone ATR fraction (0.15)
- UseLevelGrid — adaptive grid step (false), UseLevelAutoLot — auto lot by level (false)
Losing Order Trim
Forcibly closes the most losing order in the series when the remaining orders still allow reaching the profit target. Trim button on the panel.
- OFF — disabled
- Own — closes if the remaining orders of the same direction yield target profit
- Joint — closes if all remaining BUY and SELL orders together yield target profit
Filters and Protection
- Spread filter: current spread must not exceed MaxSpread points (30)
- Margin filter: free margin level must be at least MinFreeMarginLevel % (200)
- Time windows: up to three independent windows "09:00-17:00". Midnight crossing supported. If all empty — 24/7 trading
- ATR protection: if ATR = 0 (no history loaded) — all trading is blocked
- Symbol normalization (UseNormalizeSymbol): removes broker suffixes (EURUSDm to EURUSD)
Interactive Control Panel
Three tabs. White input fields accept keyboard values — click the field, type a number, press Enter to apply, Escape to cancel.
Trading tab: START/STOP, direction BUY/SELL/BOTH, Entry Mode, Dry Run (no new series, existing close normally), Max BUY/SELL, Max Lot, Profit %, BASKET ON/OFF, Individual TP, BASKET type, TRIM, ST averaging filter, BREAKEVEN, TRAILING, Lot Mult.
Grid tab: Expanding Grid, Step Mult, Stepped Martin with zones, ATR Martin with Min/Max, Levels ON/OFF, Source (Round/D-HL/ST-TF), Round step, Mode (Filter/TP/Entry/Full).
Info tab: trend and SuperTrend direction, Bid/Ask/spread, BUY/SELL series status (orders, total lot, floating profit, TP), balance and equity, drawdown, daily/weekly/monthly statistics.
System buttons (all tabs): Emergency Close — close all positions immediately, Remove Robot, Close BUY / Close SELL, panel scaling (70-200%).
Requirements
- MetaTrader 4, any symbol and timeframe
- No external DLL — full MQL Market compatibility
- Cent account support (UseCentAccount, CentMultiplier, CentBalanceBase)
Risk Notice
Grid trading involves holding multiple open positions simultaneously. During strong directional moves, drawdown can be significant. Before using on a live account, thoroughly test all settings in the Strategy Tester and select risk management parameters (initial lot, max orders, max total lot) appropriate to your account size.
Contact Us
We are open to dialogue! If you have questions about setup, suggestions for improvements, or you want to develop a trading robot based on your own strategy — feel free to send us a private message. We will discuss your needs, propose a solution, and turn your idea into a working Expert Advisor.
