Guarda come scaricare robot di trading gratuitamente
Ci trovi su Telegram!
Unisciti alla nostra fan page
Accedi al CodeBase dal tuo terminale MetaTrader 5
Non hai trovato il codice che fa per te? Ordinane uno dalla sezione Freelance
Come scrivere un Expert Advisor o un indicatore

Codici sorgente MQL5 di Librerie per MetaTrader 5

icon

La libreria di script è inoltre disponibile direttamente dall'ambiente di sviluppo MetaEditor per permetterti di imparare la programmazione in MQL5. Una volta scritta e controllata accuratamente, una libreria permette agli utenti di accelerare lo sviluppo di nuove applicazioni MQL5. Uno degli esempi illuminanti è la libreria ALGLIB che contiene molteplici funzioni di analisi numerica.

I codici sorgente della libreria possono essere scaricati e utilizzati in MetaEditor durante lo sviluppo di strategie di trading. Non possono essere lanciati separatamente in MetaTrader 5.

Invia il tuo codice
più recenti | migliori

A small include file for Expert Advisors and trade managers. It turns your risk rules into yes/no answers: how many lots does this stop allow, is the daily loss limit reached, is the maximum drawdown (static or trailing) reached, how much is at risk across all open positions, and are spread and session acceptable. The lot is never rounded up: if the broker minimum lot would risk more than allowed, the trade is skipped and the reason is returned. Limits survive a terminal restart. The library only measures: it sends no order. Includes a demo account guard (no trading by default) and a self-test with 78 checks.

A real economic-calendar news filter that also works in backtests. Export the events once with a script, then block new entries around news both live and in the Strategy Tester. Fixes the one-hour DST shift of historical calendar times.

Scores every setup type in your EA on its own record instead of lumping them into one equity curve. Rebuilds itself from the account's deal history on init so a restart cannot wipe the record. Prints a Wilson score lower bound next to the raw win rate so a three trade hot streak stops looking like an edge.

Position size from a risk amount, computed from the symbol's real tick value, tick size and volume step rather than an assumed pip value. It always rounds volume down, and when your risk is smaller than the minimum lot it says so and reports what that lot actually costs. No terminal state, so the sizing logic is testable offline - a 41-assertion test script is included.

A library of 24 MQL5 classes that watches a prop-firm rulebook -- drawdown, daily loss, payout consistency, minimum trading days, news blackout -- against any account, and flattens on breach without ever opening a position of its own.

A lightweight, OOP-compliant MQL5 header class (.mqh) for accurate pip value calculation and dynamic lot sizing across all instruments, featuring automated cross-currency rate conversion and broker volume normalization.

Three position-sizing protections that do different things; confusing them is why so many accounts get wiped out: - ladder: one contract per X of balance, always applied as a CAP, even with manual lot sizing; - floor: below the minimum capital it does not trade; a new deposit is needed; - breaker: stops at X% below the peak, at any account size, and does not rearm by itself. What this library solves and almost none does: a deposit is not profit, and a withdrawal is not a loss. The breaker measures the drop against the balance peak. Untreated, a deposit made DURING a drawdown lifts balance and peak together, and the protection stops seeing the drop exactly when it would help. Here deposits and withdrawals shift the peak by the same amount. The peak is persisted to a file: a breaker that forgets the peak on a terminal restart is not a breaker. The demo simulates a deposit at the bottom of a drawdown. Run it with the deposit on and off and compare the "drop" column.

Four EAs writing to the same file, all with FILE_SHARE_READ|FILE_SHARE_WRITE, FileSeek(SEEK_END), FileWrite, FileClose. Looks correct. Every FileOpen returns success. No error in the log. And the lines vanish. Reason: FILE_SHARE_WRITE lets all four open at the same time. All four call FileSeek(SEEK_END) and get THE SAME offset, because none has written yet. All four write at the same position. Whoever closes last wins. Three lines vanish silently. In my case: 12 events expected, 8 in the file. The fix is to open EXCLUSIVELY (no FILE_SHARE_WRITE) and retry while another EA holds the file. And to shout in the log when the retries run out: a log that fails silently is worse than no log at all, because you trust it. The demo script reproduces both modes. To see the loss, drag it onto four charts at the same time with safe mode off and count the lines in the CSV. On a single chart the defect does not show up - which is why it passes in testing and breaks in production.

Detects the gold symbol whatever the broker calls it, reads the contract specification from the terminal instead of assuming it, and turns a risk in account currency into a lot size that is correct for that broker.

A daily process writes "today's decision" (which strategy runs, or FLAT) to a file the EAs read at the open. One day the writer did not run. The EAs read yesterday's file, compared its date with TimeCurrent() - the server clock, which had stepped back to the previous day overnight - saw a match, and traded all morning on a 24-hour-old decision. No error anywhere. Two rules, both in this class: 1) staleness is judged against TimeLocal(), which always moves forward; TimeCurrent() is the last tick's stamp - it freezes without ticks and can step back on reconnect. 2) When in doubt the answer is FLAT: missing file, bad date, wrong day, empty line - every failure path returns "do nothing", and each is logged ONCE per state change, not on every tick and not never. File format: line 1 = ISO date, line 2 = decision string. The demo writes a fresh, a stale, a malformed, an empty and a missing file, and shows that only the first is allowed to trade.

Four EAs on the same symbol, each one honest on its own: each checks "do I have a position?" with its own magic number, sees none, and enters. On a demo account this reached 22 contracts on a symbol meant to carry 1, and a watchdog had to close 16 positions in one morning. The cap belongs at the door, not after the fact. ExposureCap::Allowed(symbol, lots, cap) sums the volume of every open position on the symbol - all magic numbers, manual trades included - and refuses the order BEFORE it is sent when it would breach the cap. One log line with the three numbers (held, requested, cap) says why. Deliberately simple: gross exposure, no netting of longs against shorts, no per-EA quota. It is a check, not a lock: two EAs deciding on the same tick can both pass; in practice EAs on different charts decide on different ticks. The demo script prints held / cap / room for the current symbol and shows the refusal line. Nothing is traded.

Una libreria per il recupero dei segnali di prossimità per gli indicatori basati sui canali

Una libreria compatta e con poche dipendenze che introduce in MQL5 un tipo Result in stile Rust. Le funzioni restituiscono un unico oggetto (valore o errore) invece di fare affidamento sullo stato globale di GetLastError(), rendendo così gli errori espliciti e impossibili da ignorare. Include ResultValue (tipi di valore) e Result (oggetti puntatori), una struttura Error, macro di ritorno anticipato (TRY, RETURN_ON_ERROR, ...) e callback opzionali Then/Match/MapError.

Advanced MQL5 risk management class providing deterministic lot sizing, auto-suffix detection, and cross-currency triangular conversion.

MQTTFive — implementazione completa del client MQTT 5.0 per MQL5. Funzionalità: • MQTT v5.0 — tutti i tipi di pacchetti, proprietà, QoS 0/1/2 • TCP + TLS tramite l’API nativa MQL5 Socket • Messaggi Will con proprietà (will_delay_interval, payload_format, message_expiry) • Alias degli argomenti per i PUBLISH in uscita • Controllo del flusso (Receive Maximum) • Opzioni di sottoscrizione (no_local, retain_as_published, retain_handling) • Payload binari e UTF-8 • Riprova automatica per QoS 1/2 • Zero dipendenze DLL — MQL5 puro Testato con Mosquitto 5.0 (15 test, tutti superati). Documentazione: https://github.com/chekh/MQTTFive Licenza: MIT

Libreria di protezione delle società di investimento istituzionali per MetaTrader 5.

Una libreria MQL5 orientata agli oggetti (.mqh) che sostituisce i modelli statici di rischio al dettaglio con i modelli istituzionali Volatility-Adjusted Position Sizing (VAPS) e Kelly Criterion.

ASQ Order Executor — Institutional order execution wrapper for MQL5 EAs ASQ Order Executor provides institutional-grade order execution with automatic retry logic, slippage monitoring, partial fill handling, requote management, and comprehensive execution statistics. Drop it into any EA for production-ready trade execution.

Funzione per il calcolo del lotto dalla percentuale di deposito

Dettagli tecnici Utilizza OrderSend di MQL5 con TRADE_ACTION_DEAL per la chiusura istantanea del mercato ai prezzi Bid/Ask correnti. Include una tolleranza di slippage (10 punti), una corretta corrispondenza dei volumi e la conservazione del numero magico. Esegue un loop a ritroso delle posizioni per evitare lo spostamento dell'indice durante l'esecuzione.

Institutional-grade forex session detection and analysis library for MetaTrader 5.

Economic calendar trading guard library for MetaTrader 5 with live MQL5 Calendar API integration.

A comprehensive stop-loss and trade management module offering multiple stop-loss methods (Fixed Pips, ATR-based, Swing High/Low, and Percentage) and trailing stop options (Fixed, ATR, Step, and Breakeven). It includes automatic broker stop-level adjustment, risk-reward–based take profit calculation, and visual stop-loss lines on the chart. The code follows a clean, structured architecture with a dedicated `CStopLossManager` class, standardized enums and structures, and fully documented English comments for clarity and maintainability.

Intelligent anti-tilt risk management library for MetaTrader 5.

Professional Telegram integration library for MetaTrader 5 EAs.

Runtime trade frequency adjustment library for MetaTrader 5.

Institutional risk analysis library for MetaTrader 5. Zero external dependencies. Pure MQL5 mathematics.

Centralized indicator handle management library for MetaTrader 5 EAs.

Complete deep learning library in pure MQL5. Build, train and deploy neural networks natively in MetaTrader 5. No DLLs, no Python, no external APIs.

Include una classe che convalida la combinazione di ping del terminale e latenza di esecuzione prima delle operazioni commerciali. Restituisce false se la soglia è superata.

A professional object-oriented MQL5 library designed for quantitative developers. It provides asynchronous order execution and dynamic slippage control to prevent terminal freezing during high-frequency algorithmic trading.

Una libreria JSON progettata per un uso massiccio di LLM e per una minore latenza.

Monitoraggio del consumo di memoria.

Include-file class that measures inter-tick latency, filters false alarms via a self-normalising ATR volatility gate, and broadcasts persistent lag alerts to other EAs via GlobalVariable IPC.

Se si ha accesso al codice dell'Expert Advisor, è possibile salvare i grafici del bilancio e del capitale e calcolare ulteriori criteri di ottimizzazione aggiungendo codice supplementare da questa libreria.

Consente all'EA di determinare se ci sono EA duplicati sul grafico in base alle condizioni.

Filter trades by trading sessions (London, NY, Tokyo, Sydney)

Funzione di modifica delle posizioni aperte e degli ordini pendenti

Calcolo del profitto/perdita delle posizioni (ordini aperti)

Funzione di chiusura delle posizioni e di cancellazione degli ordini

1234567891011