Experts: Session Range Desk MT5

Session Range Desk MT5:

Session-range breakout EA with ATR filtering, stop-distance sizing, optional break-even/partial close, and a shared chart desk. Hedging accounts; educational source with documented execution and coordination limits.

Session Range Desk MT5

Author: Erdem Mumin Kaynak

Overall, the risk-sizing approach is sensible, especially the use of "OrderCalcProfit()" and broker volume-step/minimum-lot checks. I recommend addressing the following before treating the EA as suitable for unattended operation. High priority 1. Fix directional lot calculation "CalcLot()" should use the actual order type, entry price, and stop price. Currently the calculation is based on a BUY/ASK-derived price relationship even when the eventual trade is SELL. Suggested interface: CalcLot(orderType, entryPrice, stopPrice, targetRisk) Then call "OrderCalcProfit()" using the actual BUY/SELL parameters. This is especially important for CFDs, metals, indices and instruments with non-trivial pricing/conversion characteristics. 2. Make desk-risk reservation atomic "MaxDailyRiskPct" currently performs a read/check/update sequence that is not atomic. Two charts can simultaneously see available risk and both enter, causing the combined planned exposure to exceed the desk limit. Consider implementing: lock → read → validate → reserve → unlock → execute → reconcile with timeout/recovery for failed orders. Until then, "MaxDailyRiskPct" should clearly remain described as a shared planned-risk threshold, not a hard exposure limit. 3. Fix EOD-close state handling Do not mark the EOD close as successfully completed when the broker rejects the close. Recommended state distinction: EOD requested EOD close successful EOD close failed → retry Only mark the action complete after confirming that the matching position is actually closed. Medium priority 4. Separate planned risk from actual daily loss The panel/documentation would benefit from distinguishing: - Open initial-SL risk - Realized daily P/L - Daily loss limit These represent different risk concepts. 5. Add optional daily-loss/equity protection If account protection is desired, add a separate "MaxDailyLossPct" mechanism rather than using "MaxDailyRiskPct" for this purpose. It should persist across restarts and prevent new entries after the limit is reached. 6. Improve partial-close state Differentiate between: - successfully closed - broker rejected - volume cannot be split - already completed This would make recovery and diagnostics more reliable. 7. Improve restart/day-lock persistence Persist and reconcile daily entry state against actual broker positions after restart to avoid duplicate-entry scenarios. Documentation I suggest explicitly stating: «"RiskPercent" represents intended initial stop-loss exposure under normal execution conditions. It does not guarantee a maximum account loss. "MaxDailyRiskPct" is a shared planned-exposure threshold, not an account-wide equity or daily-loss stop. Spread, commission, slippage, gaps, volume rounding, simultaneous signals and execution failures can cause actual exposure/loss to differ.» Priority order If only a few changes can be made for the next release: 1. Correct BUY/SELL lot calculation 2. Atomic desk-risk reservation 3. Confirmed/retryable EOD closure 4. Persistent restart/day-entry state 5. Optional hard daily-loss/equity protection The underlying design is good for an educational/source-available EA; these changes would make the risk controls considerably more robust and easier to reason about.