Topic

#mql5 programming

Everything about mql5 programming on RhinoQuant.

How to calculate position size in MetaTrader — pips, lots, leverage and the formula

What a position size calculator really decides, why a pip is not a point, why leverage is not in the formula, and how to compute lot size correctly in MQL5 — with a free calculator at the end.

Read more

Why your backtest results differ from live trading

Spread, commission, slippage, modelling mode, history quality and look-ahead bias — the real reasons a profitable MetaTrader 5 backtest turns into a losing account, and how to check each one.

Read more

Building a PDF Creation Library in MQL5 (Part 3): The Byte-Exact Writer

Two classes, about 300 lines, and one rule: never calculate a byte offset — ask the buffer where it is. CPdfBuffer and CPdfWriter turn the fragile hand-counted file of Part 1 into something a program can generate correctly every time.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 7): Arcs, Circles and Rounded Rectangles

Arcs derived from the sagitta rather than approximated with a Bézier constant, plus rounded rectangles with a per-corner radius — the one function most interface code will actually call. The geometry layer is finished here.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 6): Curves and Adaptive Flattening

Cubic Bézier curves in pure MQL5, flattened by De Casteljau subdivision that stops where the curve is already flat enough — so a gentle sweep costs few vertices and a tight bend gets the detail it needs, from one tolerance setting.

Read more

Building a PDF Creation Library in MQL5 (Part 2): Why PDFs Break

Three deliberately broken PDFs that every viewer still opens correctly — and why that is the problem. Introduces PdfValidate.mqh, the first permanent file of the library, which checks whether a file’s byte arithmetic actually adds up.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 5): Fill Rules, Holes and Borders

Two fill rules — non-zero and even-odd — and the small change to the rasterizer that turns an inner contour into a real hole: the letter A, donuts, gauges and borders, without ever guessing the background colour.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 4): Anti-Aliasing, Coverage and Compositing

Replacing the inside-or-outside test with fractional coverage, so that smooth edges and real transparency stop being two problems and become the same arithmetic.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 3): Edges and the First Filled Shape

Turning a path into pixels: edges, the winding number, and a scanline rasterizer that fills any shape — holes included — with one routine that never asks what it is drawing.

Read more

Building a PDF Creation Library in MQL5 (Part1): Writing a PDF by Hand

A PDF is a text file with an index at the bottom. Part 1 types two working PDFs by hand — 592 and 885 bytes — explains every character, then generates them from MQL5. No DLL, no library.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 2): Points, Contours and the Path

One geometry representation for every shape: points, contours and the path, with MoveTo, LineTo and Close — so a single fill routine can later draw anything.

Read more

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 1): Why the terminal needs its own 2D-renderer

Why MetaTrader 5 needs a real 2D renderer, and the two building blocks everything else rests on: an ARGB color type and a pixel surface bound to one chart object.

Read more

Swing Detector by Pullback (Smart Money Concepts)

Almost every structure-based method starts with the same question: which highs and lows actually matter? Everything downstream — market structure, BOS and CHoCH, order blocks, liquidity levels — is built on top of that…

Read more