RiskPanel Risk Based Lot Calculator and Trader MT5
- Utilities
-
Ibrahim Yahya
I build MetaTrader 5 tools that follow your rules exactly: Expert Advisors, trade managers and trade copiers that size every trade from your risk and manage it to the end, unattended on a VPS.
What I have built and run: - Version: 1.0
- Activations: 5
RiskPanel is a risk-based lot calculator and one-click trade panel for MetaTrader 5, built around one rule: never risk more than you chose. You pick the risk (a percentage of your account or a fixed amount of money) and the stop. RiskPanel sizes the lot so that, if the stop is hit, the loss is at most the amount you chose, rounded DOWN to the broker's volume step, and shows it on the chart before you click. Then BUY or SELL opens the trade with that stop and an optional take profit. It does not decide what to trade and it gives no signals.
How it protects your account
- Lot sized from your stop. You set the risk and the stop distance. The loss between the real entry price and the real stop price is priced by the terminal's own profit calculation, not by an approximate formula, so it fits forex, metals, indices, any contract size and any account currency.
- Always rounded down. The lot is rounded DOWN to the broker's volume step, never up, and then priced again at the exact lot, so the loss at the stop is never above the money you chose (before slippage, commission and swap, see the limits below).
- Hard risk cap. A maximum risk (5% of the base by default) applies in both modes, percent and money. The risk can never go above it.
- Margin check. The margin the trade needs is compared with your free margin before the order.
- Blocked buttons with a reason. When a side cannot be traded (the risk is too small for the minimum lot, the stop is too close for the broker, not enough margin, a stop line on the wrong side), its button turns grey and the panel shows a one-line reason.
- Self-checks. On start the panel tests its own maths (11 checks) and, on the first tick, 12 more cases (BUY and SELL, 3 risks, 2 stop sizes) against the broker's pricing. If one fails, the buttons are disabled and you get an alert.
- Confirmation. An optional dialog asks before each order is sent.
What you set and what you see
- Risk. A percentage of balance, equity or free margin, or a fixed amount of money.
- Stop. A distance in points, or a draggable line on the chart (a BUY needs it below the price, a SELL above).
- Target. A multiple of the stop distance, R (0 = no take profit). A target the broker would reject as too close is dropped.
- You see. Risk money, stop distance, lot / SL / TP for BUY and SELL, the loss at the stop, the gain at the target, margin needed against free margin.
- On the chart. The planned stop and target are drawn as dotted lines. Your values are remembered per symbol. The panel can be minimised.
How to use it
- Attach RiskPanel to the chart of the symbol you want to trade (any timeframe).
- Allow Algo Trading in the terminal and in the EA's settings.
- Choose the risk mode and value, then the stop (points or line) and the target.
- Check the lot, the loss at the stop and the margin on the panel. Press BUY or SELL (and confirm, if asked).
- The order carries the stop loss and take profit, so the broker holds them. RiskPanel does not manage the trade afterwards.
In the Strategy Tester, with the default inputs, RiskPanel opens a demo trade now and then so that you can see it work: BUY and SELL in turn, about every 48 bars when no position of its magic number is open, through the same code as the BUY / SELL button. In the tester only, if the risk is smaller than the minimum lot, the minimum lot is used. This happens only in the Strategy Tester, never on a live or demo account: there it trades only when you press a button.
Honest limits (please read)
- Slippage, commission and swap are not part of the lot. A real stop-out can lose a little more than the amount you chose.
- On a netting account a new trade adds to the existing position, and the stop loss and take profit then apply to the whole position.
- The broker's total volume limit per symbol (SYMBOL_VOLUME_LIMIT) is not checked. The broker rejects such an order and the reason is written to the log.
- Brokers that refuse stops on market orders will reject the order, because it carries the stop loss and take profit.
- The edit boxes, mode buttons and the draggable line of the panel were verified by a scripted UI test on a demo chart.
- RiskPanel does not decide what to trade, gives no signals and promises no profit.
Inputs
| Input | Default | What it does |
| Risk | ||
| Start in % mode (false = fixed money) | true | false = start in money mode |
| Risk, % of the base | 1.0 | Used in % mode |
| Risk in account currency (money mode) | 50 | Used in money mode |
| What the % is taken from | Balance | Balance, Equity or Free margin |
| Hard cap, % of the base, for both modes (0 = no cap) | 5.0 | The risk never goes above it |
| Stop and target | ||
| Start with the draggable stop line instead of points | false | true = drag the red line on the chart |
| Stop distance in points | 300 | |
| Take profit = this many times the stop distance (0 = no take profit) | 2.0 | R multiple of the stop; 0 = none |
| Trading | ||
| Magic number of the trades opened here | 770077 | Marks the trades opened here |
| Order comment | RiskPanel | |
| Max slippage, points | 30 | |
| Ask before sending an order | true | Confirmation dialog |
| Draw the planned stop / target levels on the chart | true | |
| Remember the panel values per symbol (global variables) | true | |
| Display | ||
| Recolour this chart dark | false | |
| Save a screenshot (MQL5 Files folder) 6 s after start | false | |
| Screenshot file name suffix | live | |
| Live chart: run a scripted test of the edit boxes, buttons and the line, then restore the values | false | Test helper, leave off |
| Strategy tester only | ||
| 0 none, 1 = open one BUY, 2 = open one SELL (through the same code as the button) | 0 | 0 = the demo trades described above |
FAQ
Does RiskPanel give signals or decide what to trade?
No. You choose the symbol, the direction, the risk and the stop. It only sizes the lot and sends the order.
Can the loss be bigger than the risk I chose?
The lot is calculated for the stop price itself. In a real stop-out, slippage, commission, swap or a gap can add a little to the loss. That is why the limits are stated above.
Why is a button grey?
That side is blocked and the panel says why in one line: for example the risk is too small for the minimum lot, the stop is too close for the broker, or the margin is not enough. Nothing is sent.
Why is the lot smaller than I expected?
The lot is rounded down to the volume step, and the hard risk cap limits the risk. A lot that would lose more than your money is never used.
Hedging or netting accounts?
Both. On a netting account a new trade adds to the existing position and the stop loss and take profit apply to the whole position.
Does it manage the trade after it opens?
No. The stop loss and take profit are sent with the order and the broker holds them.
Will it make my trading profitable?
No tool can promise that. RiskPanel keeps the planned loss of each trade at the size you chose. Whether you profit depends on your entries and your exits.
Do I need a VPS?
No. RiskPanel acts only when you press a button, so a running terminal is enough.
