MtApi5: expose TesterDeposit and TesterWithdrawal for backtesting#302
Open
biohazardxxx wants to merge 5 commits into
Open
MtApi5: expose TesterDeposit and TesterWithdrawal for backtesting#302biohazardxxx wants to merge 5 commits into
biohazardxxx wants to merge 5 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Strategy-tester-only money operations; documented like the existing TesterStop/IsTesting backtesting precedent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Direct calls to the MQL5 built-ins; both return an error response outside the strategy tester, matching the TesterStop handler. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes the MQL5 strategy-tester money functions through the MtApi5 connector so backtesting EAs driven from .NET can simulate deposits and withdrawals. MQL5 provides
TesterDeposit/TesterWithdrawalnatively, but neither was reachable from the C# client.C# client (
MtApi5) — 2 methods onMtApi5Client:bool TesterDeposit(double money)bool TesterWithdrawal(double money)MQL5 EA (
mq5/MtApi5.mq5) —Execute_TesterDeposit/Execute_TesterWithdrawalhandlers + executor registrations.mq5/MtApi5.ex5recompiled (0 errors).TestClient —
TesterDeposit/TesterWithdrawalbuttons for manual exercising (hardcoded 1000.0 amount, logs the bool result).Implementation notes
Mt5CommandTypeenum and the mq5ADD_EXECUTORtable; no collisions with existing ids.{"Money": <double>}and deserialize a JSON bool; the response path is the same proven pattern as the existingIsTestingcommand.IsTesting(): outside the strategy tester they returnCreateErrorResponse(-1, "... can be used only for backtesting"), exactly mirroring the existingExecute_TesterStop/Execute_UnlockTicksprecedent. On the C# side that means a call outside the tester throwsExecutionExceptionrather than returningfalse; inside the tester the built-in's bool result is returned. This is documented in the XML doc comments.TesterStatisticswas deliberately not included: it is only callable fromOnTester/OnDeinit, which makes it unusable over thisOnTimer/OnTickRPC bridge.Testing
MtApi5andMtApi5TestClientbuild clean in Release (MtApi5with 0 warnings; the TestClient's 334 nullable-reference warnings are pre-existing and none are in the new code).MtApi5.mq5compiles via MetaEditor with "Result: 0 errors"; the recompiledMtApi5.ex5is included.Branch is based on
devand contains tester-money changes only; the diff is purely additive with no changes to existing behavior.🤖 Generated with Claude Code