Implements `RiskGateHandler` from the [`@douglasrechia/riskgate`](https://forge.mql5.io/DouglasRechia/riskgate) package as a MetaTrader 5 service that listens on a socket and approves or rejects incoming trade signals based on a set of risk rules.
2.**KnitPkg CLI**: The KnitPkg package manager for MetaTrader. If you don't have it, you can install it by following the instructions in the [main KnitPkg repository](https://github.com/knitpkg-dev/knitpkg-mt.git).
3.**KnitPkg homepage**: See [https://knitpkg.dev](https://knitpkg.dev) for an overview and [https://docs.knitpkg.dev](https://docs.knitpkg.dev) for documentation.
## Installation
Download and build the latest stable version in a single command via the [KnitPkg](https://knitpkg.dev) registry. If MetaTrader is installed in more than one location, first change to your MetaTrader Data Folder root:
```bash
cd "C:\Users\<username>\AppData\Roaming\MetaQuotes\Terminal\<TERMINAL_ID>"
kp get mql5 @douglasrechia/riskgate-service-realcase
```
If needed, restart MetaTrader afterward to refresh the Navigator. Double-click to start the service at Services/riskgate-service-realcase/bin/RiskgateServiceRealCase.
Unit tests are in `tests/UnitTests.mq5` and cover `MyHandler` in isolation using mock implementations of all external dependencies (`MockTradeHistory`, `MockAccountInfo`, `MockOpenPositions`, `RealSymbolInfo`). The command `kp get` above already compiles the tests as a MetaTrader script under Services/riskgate-service-realcase/bin/UnitTests, just double-click on it.