Interactive Position Risk Simulator MT4
- インディケータ
-
Koji Saito
初めまして!
「FX-SAITO」として活動しているトレーダー兼ツールクリエイターです。
相場構造や値動きの分析ロジックのインジケーターを中心に開発しています。
リペイントなし・リスク管理徹底の再現性重視で、実戦で長く使えるツールを設計しています。 - バージョン: 1.0
Interactive Position Risk Simulator is a free visual position sizing, risk percentage, and stop-out simulation indicator for MetaTrader 4.
Draw Long or Short trade zones directly on your chart and drag their corners or edges to calculate optimal lot size, risk percentage, Risk-to-Reward ratio (R:R), projected profit or loss, required margin, and stop-out price in real time before placing any order.
Key Features
Visual Placement and Live Dragging: Place a Long or Short position zone anywhere on the chart using the + Long or + Short buttons on the control panel, or by pressing customizable hotkeys (default L and S). Drag the TP, SL, or Entry corners and boundaries directly on the chart to recalculate and update the opposite zone, guide lines, floating info badges, and control panel in real time.
Dual Position Sizing Modes: Choose between Risk % (Auto Lot), which computes lot size from your account balance, stop-loss distance, target risk percentage (0.1% to 99.0%), and estimated slippage, or Fixed Lot (Auto Risk %), which calculates the effective risk percentage and maximum potential loss for any chosen lot volume. Both modes can be switched inside the Edit Risk tab with automatic value carry-over.
Margin, Leverage, and Stop-Out Protection: The indicator reads live broker Required Margin and account Stop-Out Level automatically, while allowing hypothetical account testing through Custom Leverage and Stop-Out Level % overrides. Expanding the button on the center info badge reveals the Required Margin and exact Stop-Out Price. Setups that exceed lot limits, free margin, or stop-out thresholds are highlighted in warning gray with a clear status tag.
Multi-Position Workspace and Pin Overlay: Manage up to 500 simulated positions on a single chart and use the panel navigator buttons to center any position inside the chart viewport. You can pin multiple positions to display their zones and info cards together for comparison, switch direction between Long and Short with the Flip action, or enable Lock to prevent accidental dragging.
Bar-by-Bar Historical Simulation: Evaluates historical and current price action from each zone's start bar to its end bar, accounting for Open, High, Low, Close, and open gaps. The chart displays the execution diagonal line from Entry to Close or current evaluation, pixel-aligned highlight frames around the Entry and Exit/Evaluation candles, and realized or open profit/loss alongside the ending balance on the floating card.
Multi-Currency Conversion and Persistent State: Set Target Account Currency (such as USD, JPY, or EUR) to evaluate risk, profit/loss, and margin in a different currency using live and historical cross rates. All placed positions, custom colors, and panel coordinates remain saved across timeframe changes, parameter updates, and terminal restarts. Pure MQL4 implementation with no DLL imports or external web requests.
How to Use
- Attach Interactive Position Risk Simulator to any chart (compatible with both dark and light chart themes).
- Click + Long or + Short on the floating control panel (or press the L or S shortcut key), then click on the chart where you want to place the zone.
- Drag the TP/SL zone corners or Entry boundary to adjust price levels and bar duration while reviewing live updates for Lot, Risk %, R:R, Margin, and Stop-Out.
- Open Edit on the panel to refine Risk settings (Balance, Sync, Mode, and Memo), Levels (exact Entry price, TP/SL points, and bar width), or Style (a 12-color palette for TP, SL, and text, plus zone fill toggle).
Input Parameters
General and Account: Target Account Currency (blank = broker) sets the currency used for balance, profit/loss, and margin calculations when left non-blank. Use Live Account Balance for New Pos pulls your current broker balance automatically (converted to the target currency if configured), whereas Fixed Initial Balance (if false) defines the starting balance used when live balance sync is turned off.
Default Position: Position Sizing Mode selects the initial calculation method (Risk % Auto Lot or Fixed Lot Auto Risk %). Default Risk % (0.1 - 99.0) and Default Fixed Lot control the starting risk percentage or volume for new zones. Default Take Profit (Points), Default Stop Loss (Points), and Default Zone Width (Bars) set the initial target distance, stop distance, and horizontal bar span.
Margin and Stop-Out Filter: Stop-Out Level % (0 = Broker Auto, -1 = Off) configures the margin stop-out threshold (0 reads your broker value and -1 disables filtering). Custom Leverage (0 = Broker Auto) lets you test a custom leverage ratio instead of your live account leverage. Estimated Slippage (Points) adds extra points to stop-loss risk calculations for conservative sizing.
Zone and Badge Visuals: Default TP Zone Color, Default SL Zone Color, Info Badge Text Color, and Active Helper Line Color define the initial colors for zones, badges (with automatic contrast fallback), guide lines, and candle highlight frames. Auto Zone Fill Mode controls fill behavior (Per-Position Setting, Active Only, Hover Only, or Active & Hover). Highlight Entry/Exit Candles toggles candle highlight frames, and Info Badge Font Size sets the card text size from 7 to 14.
Panel and Shortcuts: Start Panel Collapsed launches the control panel in a minimized header state. Shortcut Key: Place Long (default L, or None) and Shortcut Key: Place Short (default S, or None) configure keyboard shortcuts for zone placement mode.
Important Notes
This indicator is a visual trade planning and simulation tool only. It does not place, modify, or close live orders automatically.
Bar-by-bar historical simulation evaluates chart Bid prices without adding spread to bar highs or lows. If a currency conversion pair is not present in Market Watch or lacks price history, Rate N/A appears on the badge until historical data finishes loading.
