Duration: ~1 hour | Instructor: Dr. Raymond S. T. Lee
This self-contained session introduces the MetaTrader 5 platform and MetaQuotes Language 5 (MQL5) — the essential tools for implementing Quantum Finance Forecast Systems described in the book.
MetaTrader 5 (MT5) is a multi-asset trading platform developed by MetaQuotes. It is widely used by retail and institutional traders for forex, stocks, futures, and cryptocurrencies. Key features relevant to Quantum Finance:
MQL5 is the programming language for MT5. Open MetaEditor from MT5 (Tools → MetaQuotes Language Editor or F4).
Basic MQL5 structure:
//+------------------------------------------------------------------+
//| SimpleEA.mq5 |
//+------------------------------------------------------------------+
#property copyright "Dr. Raymond Lee"
#property version "1.00"
int OnInit()
{
Print("EA initialized");
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
Print("EA removed");
}
void OnTick()
{
// Called on every new tick
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
Print("Current Ask: ", ask);
}
MQL5 uses a handle-based system for indicators and timeseries.
// Get historical closes
double closes[];
ArraySetAsSeries(closes, true);
int copied = CopyClose(_Symbol, PERIOD_D1, 0, 100, closes);
if(copied > 0)
Print("Latest close: ", closes[0]);
// Simple Moving Average example
int ma_handle = iMA(_Symbol, PERIOD_H1, 20, 0, MODE_SMA, PRICE_CLOSE);
double ma_buffer[];
ArraySetAsSeries(ma_buffer, true);
if(CopyBuffer(ma_handle, 0, 0, 1, ma_buffer) > 0)
Print("MA(20): ", ma_buffer[0]);
Create a script that prints the last 10 daily closes of the current symbol.
// Save as GetLastCloses.mq5 and run on any chart
void OnStart()
{
double closes[];
ArraySetAsSeries(closes, true);
int n = CopyClose(_Symbol, PERIOD_D1, 0, 10, closes);
if(n > 0)
{
for(int i = 0; i < n; i++)
Print(i, ": ", closes[i]);
}
}
ArraySetAsSeries() and CopyClose() / CopyBuffer() in MQL5?Submit screenshots + MQL5 code files by next session.
QF Workshop #5 – Introduction to MT5 & MQL5 | Dr. Raymond S. T. Lee