metatrader 5

Trailing stops in MQL5: how to lock in profit without choking your winners

Trailing stops in MQL5: how to lock in profit without choking your winners

I once had a long on GBPJPY that was up about 70 pips. Nice trade. I'd bolted on a trailing stop the night before, set it to follow 12 pips behind price, and went to bed feeling clever. By morning the position was closed for a 9-pip gain, and the pair had run another 180 pips in my direction without me. The trailing stop did exactly what I told it to: it strangled the trade on the first pullback. That's the whole problem with trailing stops in one story - set them too tight and they turn your best trades…
Read More
Risk management in MQL5: position sizing and stops that survive a losing streak

Risk management in MQL5: position sizing and stops that survive a losing streak

A few years back I had an EA with a 68% win rate in the tester. It looked fantastic. I dropped it on a small live account at a flat 0.20 lots per trade, left it running, and came back a week later to a 41% drawdown. The signals had behaved - roughly what the backtest promised. What drained the account was that I'd hard-coded the lot size and paid no attention to how far the stop sat from entry. A few wide-stop losers in a row, every one of them sized exactly like the tight-stop winners, and the arithmetic…
Read More
How to code Your first Expert Advisor in MQL5 in 60 minutes (with source code)

How to code Your first Expert Advisor in MQL5 in 60 minutes (with source code)

Coding your first Expert Advisor (EA) in MQL5 can feel intimidating if you’re not a programmer. The good news: you don’t need a computer science degree to build a simple, working Forex robot for MetaTrader 5 (MT5). In this tutorial you’ll go from zero to a complete EA that: Trades a Moving Average crossover strategy Uses stop loss and take profit Trades automatically using the CTrade class Can be backtested in the MT5 Strategy Tester You’ll also get the full source code, tables of parameters, and explanations of how everything works. 1. What You’ll Build (and How We’ll Do It)…
Read More