Loading…

Shadow Paper Trading Ledger

A candidate strategy that has not earned real risk yet still needs to prove itself somewhere. Backtests answer "would this have worked on history"; this ledger answers "is this working right now", side by side with whatever is actually trading, without risking a cent while it builds that record. The honesty of a paper ledger lives entirely in how it prices fills. A virtual buy that fills at the mid price instead of Ask, and a virtual sell that fills at mid instead of Bid, understates real cost on every single trade - spread is not a rounding error, it is the single biggest reason a strategy that looks profitable on paper loses money live. This ledger reads the real Bid/Ask for every open and close, so the spread the strategy would actually have paid is baked into every virtual fill from the first trade. Profit is computed from the symbol's own MODE_TICKVALUE and MODE_TICKSIZE, not a hardcoded $10-per-pip or 100000-unit contract assumption. That assumption is simply wrong for gold, most indices, and any JPY cross, and a ledger meant to be dropped onto an arbitrary symbol has to get this right or its virtual P/L is fiction on anything but a standard FX major. CheckStops() exists because a virtual position has nobody watching it the way a broker's server watches a real one. Call it every tick (or every new bar) and it closes any virtual position whose SL or TP has been crossed by the current market, using the same collect-tickets-then-act discipline this catalogue requires for real order pools - acting on a position while still iterating the open list by index is the same trap here as it is for OrdersTotal(), just with a private array instead of the terminal's own pool. Notes and limitations - This ledger never calls OrderSend, OrderClose, OrderModify or any other trading function - it is arithmetic and bookkeeping only, safe to run on any account, including a live one, with zero trading risk. - Fills are priced at the current Bid/Ask at the moment OpenVirtual/ CloseVirtual is called. It does not simulate slippage, requotes, partial fills, or the delay a real broker introduces - it is a spread-honest paper fill, not a full execution simulator. - CheckStops() only reacts when it is actually called. It is not a background timer - if your EA stops calling it (or calls it rarely on a slow-moving symbol), a virtual SL/TP can sit crossed for a while before the ledger notices, unlike a real broker-side stop. - Swap and commission are not modelled. A strategy that holds positions overnight will show a slightly optimistic virtual P/L compared to what a real account with swap charges would show. - Ledger state is in-memory only for the life of the attached script/EA/chart - it is not persisted to a file or GlobalVariable, so a terminal restart loses the open/closed history. Add your own File-based persistence around this header if a track record needs to survive a restart.

Script · MT4 · v1.0 · Free

About Shadow Paper Trading Ledger

Shadow Paper Trading Ledger is a script for MetaTrader 4. It has 2 settings, such as Virtual balance and Volume lots. MQL source code included.

Files in the download: ShadowPaperLedger.mqh, ShadowPaperLedger.txt, ShadowPaperLedgerDemo.mq4.

Settings

SettingDefaultWhat it does
Virtual balance10000.0Starting balance for the virtual account
Volume lots0.10Virtual position size in lots

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Buy/Sell Arrows · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria