KenKem Journal

Which Quant Trading Principles Actually Changed How I Build a Bot?

· #systematic-trading #quant-books #risk-management #backtesting #trading-bots

Reading a classic quant-trading book changed my bot in nine specific places, and none of them were about finding a cleverer signal. They were about removing the places where I, or my data, or my own optimism, could quietly fool me. The book is Ernest Chan's Quantitative Trading. I am a self-taught engineer, so I credit the ideas to him, keep only the principles, and describe what I did with each one in my own work.

Abstract code-drawn line art on a grid
Drawn in code, not photographed. KenKem house art.

This is a build log, not advice. The MasterVP system has no live track record I am pointing to here, and nothing below is a result.

Why must a trading rule be something a machine can run?

Because anything that cannot be written down precisely will be re-read under pressure, in whatever direction fear prefers.

"It looks like it's breaking out" is not a rule. Two people read the same chart differently, and the same person reads it differently on a good day and a bad one. "Enter when X crosses Y by Z, exit at A" is a rule, and a machine runs it identically every time.

So the bar for any idea entering my research workflow in the Dquants engine I developed is simple: it only becomes a bot feature once it is an explicit condition my MQL5 code can evaluate the same way on every bar. Anything I could only describe in words stayed a note. If I cannot encode it, I do not have a system. I have a hunch I will abandon.

What does automation actually remove, and what does it leave behind?

It removes the steps where fear, greed or hesitation can interfere. A configured Expert Advisor reads data, applies the settings the user chose, and sends the order. The decision was made calmly when the rule was written, and live execution only carries it out.

What it leaves behind is a harder problem: keeping your hands off it. The system can run itself most of the day, and the strongest urge is to stare at intraday P&L and intervene during a big swing. The swing that scares you into "just adjusting" is often ordinary noise the backtest already accounted for.

My answer was not more willpower. It was fewer override buttons. The MasterVP Expert Advisor runs to its configured session and risk limits. The Profiler indicator shows the same read and leaves the order with the user. Two doors into one method, and the user picks the one that fits their day.

Why do costs matter more than the signal?

Every trade pays a toll: commission, the spread you cross, the impact of your own order, and the slippage between the price you wanted and the price you got. The more often a strategy trades, the more those tolls compound, and a system that looks spectacular on paper can flip to a loser once realistic costs are subtracted.

A backtest that ignores costs is not a slightly optimistic estimate. It is a different strategy, one you cannot trade. So backtests in the Dquants engine subtract commission, spread and slippage on real tick data before an edge is allowed to look real. A frictionless curve never gets the chance to convince me to ship anything into the bot.

I wrote about a concrete case of this in Why Over-Trading Quietly Kills a Strategy.

What is survivorship bias, and how did it change my data choices?

Some historical datasets quietly drop the companies that went bankrupt, were delisted or were acquired. What remains is only the survivors, which paints a rosier past than anyone lived through. It bites hardest on "buy what is cheap" strategies, because some of those names were cheap precisely because they were about to fail.

I do not trade single stocks, so the direct version does not apply to my bots. The principle still did. The research runs on full real-tick history for the instrument the bot actually trades, XAUUSD, rather than a cleaned-up sample that forgot its losers. Before trusting any backtest I ask a boring question: where did the failures go?

Why is a simple model usually the one that survives?

Give a model enough knobs and you can make any past look beautiful. But then you have not fitted the real pattern. You have fitted the random accidents of one particular history, which will not repeat. That is overfitting, and it can sneak in with just a couple of tuned thresholds and get worse with every rule you add.

The models that keep working after the backtest ends tend to be simple ones with few moving parts you can defend. The MasterVP core is deliberately small, a handful of Volume Profile rules I can explain. In the Dquants engine, any threshold that only shines on one slice of history gets cut from the bot rather than kept. I would rather have few rules I understand than a curve that flatters history.

Should you trust the position-sizing formula literally?

No. The Kelly criterion tells you the size that maximizes long-term growth: roughly, risk in proportion to your edge and inversely to your noise. It turns "how much should I risk?" from a gut feeling into a calculation, which I like.

But the answer is only optimal if you know your true edge exactly and returns behave like a tidy bell curve. I do not know my edge exactly, and real markets throw far more extreme moves than that math assumes. Experienced traders deliberately bet half the formula's figure, or less. Trusting it literally is its own kind of overconfidence.

So the Expert Advisor's sizing and caps sit well under what the formula would suggest. The defaults trade a little theoretical growth for more survivability. The longer version is in Kelly Criterion Position Sizing for Systematic Traders.

What actually ruins a good strategy?

Usually not a bad strategy. When large funds blow up suddenly, the cause is more often too much leverage than a fundamentally broken model. Nobody bets big on a strategy they think is bad. The dangerous moment is a winning one, where confidence tempts you to size up right before a rare, violent move.

That is why the Expert Advisor enforces a hard maximum daily risk and fixed position caps in code. A winning streak cannot talk me into a size that a rare violent move could punish. The enemy is not the losing system I would never fund. It is the good one I trusted too much.

Is being small a disadvantage?

Less than it sounds. An edge is not infinitely scalable. Push more capital in and you start moving the market against yourself, so return per dollar shrinks. That ceiling is called capacity, and it is why some genuine edges are too small for a large fund to bother with.

Being small is a structural benefit: you can deleverage almost instantly, or sit fully in cash. I built MasterVP for that corner, five and ten minute work on XAUUSD, precise setups with limited capacity. I treat that as the advantage to build on, not a handicap to apologize for.

Why do edges have half-lives?

A glowing ten-year backtest can be carried entirely by a market regime that no longer exists. Markets move through phases, and competition is corrosive: it grinds mean-reversion opportunities toward zero and shortens how long a trend stays profitable as news spreads faster. A strategy with permanently frozen parameters is quietly betting that the world never changes. The polite name for the result is alpha decay.

So the question is not "did it work?" It is "is it still working, and how will I know the moment it stops?" I keep re-testing the MasterVP rules against fresh tick data in the Dquants engine and watch for expectancy starting to fade. Parameters are reviewed on evidence, not frozen and forgotten.

What did I change, in one list?

  • Ideas must be codeable rules, or they stay notes.
  • Execution is automated, and override buttons are removed rather than resisted.
  • Costs are subtracted first, on real ticks.
  • Research uses full history for the instruments I actually trade.
  • The model stays small enough to defend.
  • Sizing sits under what the formula suggests.
  • Risk caps are hard-coded, so a good run cannot talk me into more.
  • I stay in the corner where small is an advantage.
  • I assume decay and keep re-testing.

None of this guarantees anything. It lowers the number of ways I can fool myself, which is the part of the job I can actually control.

Frequently asked questions

Is this financial advice? No. It is a description of how one self-taught engineer builds software. Educational purpose only.

Which book are these ideas from? Ernest Chan's Quantitative Trading. I credit the principles to him and do not republish his specific trades, parameters or numbers.

Does MasterVP have a live track record you can show here? Not in this article. I am describing method, and any backtest comes with the caveat that a backtest is not live trading.

Do you trade single stocks? No. MasterVP trades XAUUSD, which is why survivorship bias shows up for me as a data-hygiene principle rather than a direct risk.

Why not just add more rules to improve the backtest? Because every extra rule is another place to fit noise. Few rules I can defend beat many I cannot.

Does automation mean I never look at the system? No. I monitor for genuine breakdown. I just do not second-guess the configured system because one number frightened me.

Why size below the Kelly figure? Because the formula assumes I know my true edge and that returns are well behaved. Neither is true, so I trade a little theoretical growth for survivability.

What is the one idea to start with? Write your rule down precisely enough that a machine could run it. Everything else gets easier to test after that.


Written by a self-taught engineer who builds trading software and shares the process in the open. Composed from the KenKem build-log series. Educational purpose only. Not financial advice. Past performance does not guarantee future results.

← All journal articles

Chat