An Expert Advisor that never leaves a position unprotected.
We build MetaTrader EAs the careful way: the stop ships in the same request as the entry, fills worse than your slippage are refused, and requotes are handled instead of swallowed. Most of the work in a real EA is the gap between a strategy on paper and how a broker actually fills, and that's exactly the part we sweat.
The EA, in real MQL5.
The whole logic is a small file you can read: on a closed bar, if price breaks the range, send the order with its stop and target attached in the same request. No position is ever open without an exit.
1// EsBreakout.mq5 — enters with the stop and target in one request2void OnTick()3{4 if(!IsNewBar() || PositionExists(_Symbol)) return;56 double upper = HighestHigh(Lookback); // prior N-bar high7 double atr = AtrValue(AtrPeriod);89 if(iClose(_Symbol, PERIOD_M5, 1) > upper)10 {11 MqlTradeRequest req = {};12 MqlTradeResult res = {};13 req.action = TRADE_ACTION_DEAL;14 req.symbol = _Symbol;15 req.type = ORDER_TYPE_BUY;16 req.volume = LotsForRisk(atr);17 req.price = Ask;18 req.sl = Ask - 2.0 * atr; // stop, same request19 req.tp = Ask + 3.0 * atr; // target, same request20 req.deviation = MaxSlippage; // reject a worse fill2122 if(!OrderSend(req, res) || res.retcode != TRADE_RETCODE_DONE)23 HandleReject(res.retcode); // requote / no-fill handled24 }25}The stop ships with the order.
Plenty of EAs open a position, then send the stop as a second step. If that step lags on a fast move, you're naked. The stop and target go in the same request, so the position is protected from its very first tick. A requote is caught and re-priced, not ignored.
A position that's never unprotected.
Here it is on the terminal: the stop and the target were set the instant the order filled, and the profit ticks between them. There's no window where the trade is running without a plan to exit.
An EA does exactly what you told it, forever, without getting bored or scared.
That's the strength: precise, tireless execution of your rules, 24/5, with a stop attached to every order and every action logged. And that's the whole limitation too. It executes your edge, it doesn't invent one. A tireless machine running a losing strategy just loses faster. We build the machine well. The strategy is the part that has to be yours.
An Expert Advisor that never leaves a position unprotected.
The stop ships in the same request as the entry, fills worse than your slippage are refused, and requotes are handled instead of swallowed.