Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Views:
40
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Before every trade, a trader has to answer one question: how many lots can I open so that a stop loss hit costs exactly the risk I chose? This script answers it in one click. Drop it on any chart, enter your risk in percent and your stop distance in points, and it shows the lot size to trade together with the real money at risk after rounding.


Many lot calculators rely on the tick value alone. On some brokers this is wrong for gold, indices, stocks and cross pairs, because of the contract size, the profit currency or the way the broker reports tick values. This script does not guess: it asks the terminal how much a 1.0 lot buy would lose over your stop distance, using the built-in OrderCalcProfit() function. The broker's own rules for contract size, tick value and currency conversion are therefore applied automatically.


The lot size is always rounded down to the broker's volume step, so the trade never risks more than you asked for. The script then shows the actual risk of the rounded lot, in money and in percent. If even the minimum lot is too big for your risk, it does not suggest a trade: it tells you how much the minimum lot would actually risk, so you can decide yourself.

The result appears in an alert window, in the Experts log and in the top-left corner of the chart:


First line: the symbol, your risk in percent and in account currency, and the stop distance in points.

Second line, "Lot size": the lot to trade, followed by the actual risk of that lot after rounding.

Second line, "Too small": your risk is below what the minimum lot needs; the line shows the risk of the minimum lot instead.


Input parameters:


The stop distance is entered in points, the smallest price step of the symbol, so one input works on every market. On a 5-digit EURUSD quote, 10 points are 1 pip. On a 2-digit gold quote, 100 points are 1.00 USD per ounce, so 500 points are a 5.00 USD stop. On a 3-digit gold quote, the same 5.00 USD stop is 5000 points.


Example: on a 10,000 USD account, XAUUSD quoted with 2 digits, 1% risk and a 500 point stop, one lot of 100 ounces loses 500 USD, so the script shows 0.20 lots with an actual risk of 100 USD. Run the script while the market is open, so the symbol has a current price. The two helper functions, LossPerLot() and RoundLots(), are short and commented and can be reused in your own Expert Advisors.

Input Default Description
RiskPercent 1.0 Risk per trade, in percent of the balance or the equity
StopPoints 500 Stop loss distance in points (the symbol's smallest price step)
UseEquity false true: percent of equity; false: percent of balance


Same H4 and D1 candles on every broker - NY close candles from H1 Same H4 and D1 candles on every broker - NY close candles from H1

Builds H2 to D1 candles from H1 on the New York close clock, so your indicators see the same candles on every broker, no matter which server time it uses. Detects the server clock automatically.

Can I trade right now - session, session end and quote check in one call Can I trade right now - session, session end and quote check in one call

One call before you send an order: is the session open, how long until it closes, are quotes still coming in, is trading allowed. Gives you the reason when the answer is no.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.