Interactive Position Risk Simulator MT5
- インディケータ
-
Koji Saito
初めまして!
「FX-SAITO」として活動しているトレーダー兼ツールクリエイターです。
相場構造や値動きの分析ロジックのインジケーターを中心に開発しています。
リペイントなし・リスク管理徹底の再現性重視で、実戦で長く使えるツールを設計しています。 - バージョン: 1.0
Interactive Position Risk Simulator is a free visual position sizing, risk percentage, and stop-out simulation tool built for MetaTrader 5.
Plot Long or Short trade zones directly on the chart and drag their corners or borders to inspect optimal lot volume, risk percentage, Risk-to-Reward ratio (R:R), projected profit or loss, required margin, and stop-out price in real time prior to order entry.
Key Features
Visual Placement and Live Dragging: Place a Long or Short trade zone anywhere on the chart via the + Long and + Short panel buttons or customizable hotkeys (default L and S). Adjusting the TP, SL, or Entry corners and edges updates the opposing zone, guide lines, floating info cards, and control panel in real time.
Dual Position Sizing Modes: Switch between Risk % (Auto Lot), which determines lot size from account balance, stop-loss distance, target risk percentage (0.1% to 99.0%), and estimated slippage, and Fixed Lot (Auto Risk %), which calculates the resulting risk percentage and maximum potential loss from a fixed volume. Mode switching is available in the Edit Risk tab with automatic value carry-over.
Margin, Leverage, and Stop-Out Protection: Automatically reads live broker Required Margin and account Stop-Out Level, with options to simulate hypothetical account conditions via Custom Leverage and Stop-Out Level %. Expanding the center info card reveals Required Margin and the exact Stop-Out Price. Configurations exceeding lot limits, free margin, or stop-out levels turn warning gray with an explanatory status tag.
Multi-Position Workspace and Pin Overlay: Track up to 500 simulated positions on one chart and center any setup in the viewport using the panel navigator controls. Multiple positions can be pinned simultaneously for side-by-side comparison, reversed between Long and Short with Flip, or secured against unintended edits with Lock.
Bar-by-Bar Historical Simulation: Analyzes price bars from the zone start time to the end time, including Open, High, Low, Close, and open gaps. The chart renders an execution diagonal line connecting Entry to Close or current evaluation, pixel-aligned highlight frames on Entry and Exit/Evaluation candles, and realized or open profit/loss plus ending balance on the info card.
Multi-Currency Conversion and Persistent State: Define Target Account Currency (for example USD, JPY, or EUR) to compute risk, profit/loss, and margin in another currency using live and historical cross rates. Positions, color choices, and panel coordinates persist across timeframe switches, input changes, and terminal restarts. Pure MQL5 implementation with no DLL imports or external web requests.
How to Use
- Attach Interactive Position Risk Simulator to a chart (suitable for both dark and light chart backgrounds).
- Press + Long or + Short on the control panel (or use the L or S hotkey), then click on the chart to place the zone.
- Move the TP/SL zone corners or Entry boundary to adjust price targets and duration while observing live Lot, Risk %, R:R, Margin, and Stop-Out figures.
- Click Edit on the panel to configure Risk (Balance, Sync, Mode, Memo), Levels (precise Entry, TP/SL points, bar width), or Style (12-color palette for TP, SL, and text, plus zone fill toggle).
Input Parameters
General and Account: Target Account Currency (blank = broker) specifies the target currency for balance, profit/loss, and margin figures when provided. Use Live Account Balance for New Pos pulls your active broker balance for new zones (converted when needed), while Fixed Initial Balance (if false) supplies the starting balance when live balance sync is disabled.
Default Position: Position Sizing Mode sets the default calculation behavior (Risk % Auto Lot or Fixed Lot Auto Risk %). Default Risk % (0.1 - 99.0) and Default Fixed Lot specify initial sizing values. Default Take Profit (Points), Default Stop Loss (Points), and Default Zone Width (Bars) control the initial TP distance, SL distance, and bar width of newly placed zones.
Margin and Stop-Out Filter: Stop-Out Level % (0 = Broker Auto, -1 = Off) sets the margin stop-out percentage (0 uses your broker setting and -1 disables filtering). Custom Leverage (0 = Broker Auto) lets you test custom leverage instead of the broker default. Estimated Slippage (Points) adds conservative buffer points to stop-loss calculations.
Zone and Badge Visuals: Default TP Zone Color, Default SL Zone Color, Info Badge Text Color, and Active Helper Line Color customize zone colors, badge text (with automatic contrast fallback), guide lines, and candle highlight frames. Auto Zone Fill Mode manages fill visibility (Per-Position Setting, Active Only, Hover Only, or Active & Hover). Highlight Entry/Exit Candles toggles Entry and Exit bar frames, and Info Badge Font Size adjusts badge text from 7 to 14.
Panel and Shortcuts: Start Panel Collapsed initializes the panel in its compact header state. Shortcut Key: Place Long (default L, or None) and Shortcut Key: Place Short (default S, or None) assign hotkeys for placing zones.
Important Notes
This indicator is designed strictly for visual trade planning and simulation. It does not execute, modify, or close live trades automatically.
Historical bar-by-bar evaluation uses chart Bid prices without adding spread to bar highs or lows. When a required conversion pair is missing from Market Watch or lacks sufficient history, Rate N/A is displayed until the data loads.
