Day: October 22, 2026

The Expert Advisor compiles. Now read the order handling The Expert Advisor compiles. Now read the order handling 

 

A language model will write MQL4 that builds without a warning and reads as though it has already been reviewed. It has not been. 

Zero errors, zero warnings, and nothing settled 

The compile step checks that the file is legal MQL4. Whether the program does what you asked is a separate question with no button attached to it. A model trained on a great deal of published code is very good at the first of those, because legal syntax is the regularity such training captures best. 

What arrives also looks reviewed 

Consistent naming, tidy indentation, inputs grouped at the top, a comment above every function. Those are the signals a reviewer uses to judge how careful an author was, and none of them here came from care. There are no hedges either, so the usual route to an author’s weakest passage is closed. 

The return value is where the conversation happens 

OrderSend hands back a ticket number when the broker accepts the instruction and minus one when it does not. Generated code calls it as though it were a procedure with no result, or assigns that result to a variable nothing mentions again. Either way the program cannot tell whether it holds a position or stands flat. 

Nothing crashes. The program carries on reasoning about a trade that was never opened, and every branch downstream inherits the error while looking ordinary on the page. 

The accessors keep answering after OrderSelect has failed 

OrderSelect fails worse. Its accessors keep returning values from whichever order was selected last, so the next lines read plausible numbers belonging to a different trade. 

One trade context, and the code assumes it is free 

The terminal runs a single trade thread. If an expert is inside a trade operation when a second one begins, the second is refused, and refusal is ordinary rather than exotic. Two charts running two experts, a manual click landing mid-loop, a requote taking longer to come back than the code allowed for. Any of those turns up in a normal week. 

Somebody who has met this writes a check before the call and a considered response after it. The generated version writes the happy path, because that is what nearly every published example shows and published examples are what the model read. The failure is quiet: nothing is logged, no alert fires, and the chart afterwards looks like a market that moved without you. 

A fill for less than you asked for 

The size requested and the size opened are different numbers, and only one usually appears in the file. 

Ask for a lot, receive six tenths of one, and the question is what the closing routine does. Sized against what the program intended it asks to close more than exists and is refused; sized against OrderLots() it closes what is there. 

The refusal is survivable because it is loud enough to notice. The residue costs money: a fraction of a position left open, referred to by no line left in the file, accruing financing until somebody happens to look at the terminal. Generated code reaches for the fixed number here, because the fixed number is the one the request mentioned. 

Six searches to run before the first careful read 

Reviewing unfamiliar code starts with searching rather than reading, because the quickest defects to find are absences and absences are invisible when you read forwards. Open the expert, look for six strings, and note which return nothing. Ten minutes, no view on the strategy. 

What each absence means is specific to this language and to how this class of code goes wrong. None of the six touches whether the rules are worth running. All bear on whether the program faithfully implements the rules it has, the only question a review can settle. Omissions are also all a search finds, and each of the six can be present and useless: a return value tested into an empty failure branch passes the list, and so does a magic number applied in one loop out of three. Code that is there and wrong is the harder half. 

Search the file for  What you are checking  What an empty result means 
OrderSend  the ticket it returns is stored and tested  a refusal cannot be told from a fill 
OrderSelect  the boolean is checked before any accessor runs  later lines may read another order’s values 
GetLastError  a failure reaches somewhere a person reads  every refusal passes in silence 
OrderLots()  closes are sized against what is open  a partial fill leaves an orphaned residue 
OrderMagicNumber  loops touch only this program’s orders  it will close trades it never placed 
a decrementing counter  deletions happen inside a shrinking list  a forwards loop skips an entry per removal 

Six strings to search for in a generated expert, what each one is checking, and what an empty result means. 

The comments were generated beside the code, not against it 

In an ordinary review a comment that disagrees with the line beneath it is a useful find. Somebody changed one and forgot the other, so you trust the code, fix the comment and move on. That inference quietly stops working here. Prose and logic came out of one pass from one request, so a comment describing risk management is evidence of what was asked for and of nothing else. 

The expensive version is the confident one. A line announcing that every position closes before the weekend, above a loop that walks the order list forwards while deleting from it and so steps over an entry after each removal. The comment states the intention accurately. The code is a near miss in the same clothes, much harder to see once the sentence above has told you what to expect. 

A developer with a model gets more done than one without 

None of this argues against the tool. Handed a well-specified, tedious job, the input block, the log formatting, an indicator formula lifted out of a paper into a function, it is fast and usually right, and checking beats typing. Anybody who has written a few thousand lines of MQL4 by hand will ship more with one open than without. 

The awkward part is who that helps. The value lands with whoever can read what came back, so the people best placed to review a generated expert are those who needed the help least. 

Somebody with no code at all gets a file they cannot audit and a build they will mistake for evidence. The tool multiplies the skill brought to it, and this is what multiplying by nothing looks like. 

The conditions that break this code are the ones a careful test avoids 

Almost everything an expert does against a broker is recorded twice, in the platform’s history and on the account statement, both time-stamped and checkable. Settling a question by opening an account, running something in it and reading the bill is the right instinct one layer down too, and the page on putting a language model to work on MQL4 code belongs to a site that opens and funds live accounts with its own money to test UK trading platforms rather than compiling rankings from providers’ published fee schedules. 

Notice what that produces here, though. Somebody testing a platform deals on purpose, in a size they chose, at a moment they chose, and a well-run session is one where nothing awkward happened. Every defect above needs the reverse: a refusal, a partial fill, a second trade operation arriving mid-loop, a quote that came back too late to be any use. Those are the events a competent account holder spends the afternoon steering around, so the weather this code fails in is close to the opposite of the weather a platform gets measured in. Nor is there a published defect rate for generated MQL4 to fall back on, and inventing one would be a poor way to argue for care. 

Describe it back to me without looking 

The question worth putting to anybody about to run an expert is what the file does when OrderSend returns minus one. Not what it ought to do. What the code in front of them does. If the answer takes longer than a moment, they have read the comments and the input list and formed an impression from the indentation. 

Put the question to the file, not to whoever prompted it 

That generalises cheaply. Pick the three things that must go wrong for real money to leave the account, then put each to the file rather than to whoever prompted it. Approval means you could describe the program’s behaviour with the editor closed. It has never meant that the thing built. 

 …