RobotFX curates the best open-source MetaTrader code to inspire your trading automation.
Risk and Lot Size Calculator helps you size every trade correctly before you place it. Instead of guessing the lot, you set your stop loss on the chart and the indicator tells you exactly which lot keeps your risk at the level you chose.

The indicator is a calculator only. It never opens, modifies or closes trades.
How to use:
1. Attach the indicator to a chart. Three lines appear: Entry (gold), Stop Loss (red) and Take Profit (green).
2. Drag the Stop Loss and Take Profit lines to your levels. Put the stop loss below the entry for a buy, above the entry for a sell.
3. Read the panel: direction, distances in points, reward-to-risk, lot size, real risk, profit at take profit and required margin.
4. Use the lot size shown when you place your order.
What the panel shows:
- Direction (BUY / SELL), detected from the position of the stop loss
- Entry, stop loss and take profit prices with distances in points
- Reward : risk ratio
- Risk target in money (and %)
- Lot size, rounded DOWN to the broker's volume step, so you never risk more than planned
- Real risk at that lot (shows a warning if the minimum lot is bigger than your risk)
- Profit at take profit
- Margin needed (warning colour if it is more than your free margin)
Accurate for every symbol:
Money values are calculated with OrderCalcProfit(), so they include the contract size and the currency conversion of the symbol: forex, gold, indices and synthetic indices. If the broker does not support it, the indicator falls back to tick value and tick size.
Inputs:
- Risk mode: % of balance, % of equity, or fixed money amount
- Risk value: for example 1 = 1%
- Entry line follows market price: on = the entry line stays on the current Ask (buy) or Bid (sell); off = you can drag it to plan a pending order
- Default SL distance in points (0 = automatic) and default take profit multiple (R:R)
- Panel position and width
Keys:
- R = reset the lines around the current price
- H = hide / show the panel
The lines are kept when you change the timeframe or the inputs, and everything is removed when you remove the indicator.
Screenshots to upload (take them yourself):
1. Buy setup: SL below entry, TP above, panel with lot size
2. Sell setup: SL above entry, TP below
3. The inputs window
4. Optional: gold and a synthetic index, to show it works on any symbol
Unique stair-step trend trading with the Stairsteps Expert Advisor. Innovative approach for consistent results. Learn more.
Build better strategies with RobotFX professional tools – check them out.
80164