MetaEditorのヘルプ → MCP and AI → Examples → Generating Boilerplate Code and Frameworks

Generating Boilerplate Code and Frameworks Using AI

Adapt file names, symbols, periods, risk limits, and requirements to your project or preferences. Preserve an unchanged baseline and test the algorithm in a demo environment before live use.
 
You are solely responsible for AI-generated content, AI-assisted actions, trading decisions, trading results, and any resulting losses.

C++ DLL import scaffold:

Generate a minimal 64-bit C-plus-plus and MQL5 DLL bridge for one scalar function and one numeric array of at most 128 elements. Define exports, calling convention, fixed-width types, ownership, lengths, and errors. Add memory-safe import declarations and test code for three round trips, normal, boundary, and invalid, and document the required compiler, build settings, and terminal permission. Describe the function.

Zero-wait multi-timeframe boilerplate:

Create H4-trend and M5-entry boilerplate for one symbol using 200 H4 and 500 M5 bars. Preload CopyRates and CopyBuffer data. Validate counts, BarsCalculated, ordering, and timestamps. Use ArraySetAsSeries and bounded ArrayResize consistently. Isolate timeframe state. Release handles and dynamic resources on failure and OnDeinit, and block trading whenever the readiness matrix shows stale or incomplete data.

ONNX tensor-mapping scaffold:

Inspect this ONNX model and generate its MQL5 inference wrapper. Map exact tensor names, ranks, shapes, types, feature order, normalization, and dynamic dimensions. Reuse buffers safely, and compare 10 fixed Python vectors before exposing any trading output. Report unsupported operators or ambiguous shapes. Provide the model and preprocessing contract.

Experiment-provenance framework:

Generate an experiment manifest that assigns one ID and records source-and-input hashes, tester settings, symbol properties, dates, data mode, costs, metrics, artifacts, instructions, and parent ID. Demonstrate it on one EURUSD H1 test over the previous five trading days using Open prices, and add one reproducibility check that detects a changed input.

Causality and leakage guard library:

Generate availability-aware accessors for CopyRates, CopyBuffer, news, and external model output. Tag each value with its availability time, reject incomplete or future data, map timeframes by timestamp, and include six assertion cases covering valid, stale, missing, and future observations.

Execution state-machine framework:

Generate an event-driven execution state machine for intent, validation, submission, acceptance, partial-fill, fill, cancellation, rejection, protection, and reconciliation. Correlate OnTradeTransaction events, bound retries to three, persist recovery state, and test six sequences including duplicate and reordered events.

MQL5-Python-ONNX feature contract:

Generate one versioned feature schema shared by Python training, ONNX export, and MQL5 inference for at most 20 features. Define order, shape, type, unit, scaling, missing-values, lookback, and availability time. Produce 10 golden vectors, and reject incompatible models or schemas visibly.

Monte Carlo execution-stress harness:

Generate a deterministic stress harness that replays the latest 50 recorded trade intents from one EA, or all available if fewer, through 30 seeded scenarios varying spread, slippage, delay, rejection, partial-fill, missed trade, swap, and small parameter changes. Do not wait for new intents. Export the scenarios that breach drawdown or exposure limits.

Broker-portability adapter:

Generate a broker-portability layer and demonstrate it on EURUSD and XAUUSD. Resolve aliases. Read contract and session properties. Normalize price, volume, filling, stops, and margin, and print clear diagnostics when either symbol cannot support the requested operation.

Expert Advisor project skeleton:

Generate a lean MQL5 EA project with signal, risk, execution, and logging interfaces, one concrete implementation of each, explicit lifecycle ownership, and a working entry point. Omit registries, factories, and extension layers not required by this example.

Safe lifecycle template:

Create a no-trade lifecycle template that safely owns one indicator handle, one timer, one file, one chart object, and one dynamically allocated object. Cover successful initialization, failure after each allocation, reinitialization, and OnDeinit cleanup.

Trade-request wrapper:

Generate a trade-request wrapper with validation, correlation IDs, acceptance-versus-fill tracking, netting and hedging support, three attempt retry limits, and classifications for five representative retryable or permanent return codes.

Strategy Tester presets:

Create five tester presets for the same EA and inputs. A one-week smoke test, one month deterministic regression, one month real-tick validation, one month doubled-cost stress test, and one month sealed out-of-sample test. Explain which settings must remain identical.

Optimization range file:

Inspect this EA and create an optimization range in set format for at most four justified numeric inputs, using three coarse values per input and no more than 81 combinations. Exclude identifiers and safety limits, explain each range, and do not start optimization.

Structured diagnostic logging:

Generate a lightweight structured logger with severity, time, symbol, timeframe, event, request ID, and key value fields. Demonstrate one signal decision and one trade transaction, disable verbose formatting in production, and never log credentials.

Research project scaffold:

Create a research-project scaffold for one symbol, timeframe, and three-month experiment. Hypothesis, data assumptions, MQL5 prototype, tester preset, input set, immutable baseline report, experiment log, and result summary. Use names that trace every artifact to source, parameters, symbol, timeframe, model, and dates.