RiskPanel Risk Based Lot Calculator and Trader MT5

  • Utilities
  • Ibrahim Yahya
    Ibrahim Yahya
    • MQL5 & Python developer: EAs, trade copiers, MT5 automation at  Self-employed
    • Palestine
    • 219
    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

  1. Attach RiskPanel to the chart of the symbol you want to trade (any timeframe).
  2. Allow Algo Trading in the terminal and in the EA's settings.
  3. Choose the risk mode and value, then the stop (points or line) and the target.
  4. Check the lot, the loss at the stop and the margin on the panel. Press BUY or SELL (and confirm, if asked).
  5. 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

InputDefaultWhat it does
Risk
Start in % mode (false = fixed money)truefalse = start in money mode
Risk, % of the base1.0Used in % mode
Risk in account currency (money mode)50Used in money mode
What the % is taken fromBalanceBalance, Equity or Free margin
Hard cap, % of the base, for both modes (0 = no cap)5.0The risk never goes above it
Stop and target
Start with the draggable stop line instead of pointsfalsetrue = drag the red line on the chart
Stop distance in points300
Take profit = this many times the stop distance (0 = no take profit)2.0R multiple of the stop; 0 = none
Trading
Magic number of the trades opened here770077Marks the trades opened here
Order commentRiskPanel
Max slippage, points30
Ask before sending an ordertrueConfirmation dialog
Draw the planned stop / target levels on the charttrue
Remember the panel values per symbol (global variables)true
Display
Recolour this chart darkfalse
Save a screenshot (MQL5 Files folder) 6 s after startfalse
Screenshot file name suffixlive
Live chart: run a scripted test of the edit boxes, buttons and the line, then restore the valuesfalseTest helper, leave off
Strategy tester only
0 none, 1 = open one BUY, 2 = open one SELL (through the same code as the button)00 = 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.

More from author
LadderGuard is a trade manager and account guard for MetaTrader 5. You attach it to one chart, and it looks after the positions you already have, whether you opened them by hand or another Expert Advisor did. It does not open trades and it does not generate signals. It takes partial profits at the targets, moves the stop to break-even, then moves it up level by level. It also watches the whole account and locks trading when a daily loss or drawdown limit is hit. What it does Trade manager You ch
NewsGuard protects your open positions from news spikes. You attach it to one chart, and it reads the economic calendar built into MetaTrader 5. When an important event for your currencies is close, it looks after the positions you choose: it warns you, secures them with a break-even stop, or closes them. It does not open trades and it does not generate signals. What it does Guards positions around news. Inside a window (by default 15 minutes before to 15 minutes after the event) it applies the
GoldSessions is a chart indicator for MetaTrader 5. For every day it draws one box per trading session: Asian, London and New York. The top edge of a box is the session high, the bottom edge is the session low, and optional labels show both prices. You see where each session ended and how wide it was, so you do not walk into a thin or volatile session hand-over blindly. It is a read-only chart tool: it never opens, modifies or closes a trade, uses no DLLs and makes no web requests, so it cannot
Filter:
No reviews
Reply to review