Code a function that returns the correct lot size basing on two inputs: stop loss and balance to risk

Работа завершена

Время выполнения 11 дней
Отзыв от заказчика
_Techno_ did a great job that no one else on the Forums was able to do. He is a real pro and the code delivered works perfectly and with any broker and is easy to read and as optimized as it can get. Communication was always prompt and on time and very professional and friendly as well. I can highly recommend him!

Техническое задание

Hello Coders,

I am looking for a function (not a complete EA, but a function that I can use from any of my EA´s that I code) that I simply can call like:


Lotsize = ExampleLotFunction(BalanceToRiskInPercent, StopLossPrice);

so for example with values:

Lotsize = ExampleLotFunction(2, 1.23456);


... and it returns the correct lot-size to risk exactly 2% of my current Account balance in my base-currency with the StopLoss passed to it and taking into account the account-base-currency and ANY conversions needed of course if the pair I trade is not in the account-base-currency (example: trading the AUDNZD on a account with the base currency EUR). I have found code on the forum that does work correctly if my account-base-currency is included in the pair that I trade (example: EUR is the account-base-currency and I trade EURUSD), but none yet that calculates correctly if trading AUDNZD, GBPCAD, NZDJPY or whatever and my account-base-currency is in EUR. Hence this request here in the hope someone can finally code something like this for me:)

The code should be of good quality and just be in a simple complete function so that I can use it for any of the EA´s I will be coding in the future without creating a mess and just should take those 2 input variables: Percent of current account balance to risk for the current trade by taking into account the stop loss I´ve passed to it.

Of course it should also be highly adaptive and should have no hard-coded constraints, meaning that it should adapt to different account-base-currencies, 4 and 5 digit brokers, check for the correct lot-step, lot-min and lot-max, etc. etc. Just what a professional function requires.

Thank you:)


P.S.: IMPORTANT: THS IS FOR MT4, not MT5 !


Откликнулись

1
Разработчик 1
Оценка
(473)
Проекты
1139
44%
Арбитраж
51
31% / 33%
Просрочено
501
44%
Свободен
2
Разработчик 2
Оценка
(187)
Проекты
367
56%
Арбитраж
45
22% / 56%
Просрочено
188
51%
Свободен
Опубликовал: 1 статью, 6 примеров
3
Разработчик 3
Оценка
(24)
Проекты
98
83%
Арбитраж
4
0% / 25%
Просрочено
9
9%
Свободен
Опубликовал: 6 примеров
Похожие заказы
Busco un desarrollador experto en MQL5 (MetaTrader 5) para construir un Expert Advisor (EA) completamente autónomo, robusto, escalable y con panel on-chart, incluyendo 3 módulos de estrategia parametrizables, compatibilidad con Strategy Tester, y logs detallados. El EA será de propiedad exclusiva del cliente y debe entregarse con código fuente (.mq5). Alcance obligatorio (sin recortes) Estrategia 1 — Cruce de Medias
I want to convert trading view pine script to mt5 expert advisor. Pine script is given below. Pine script is working very well in xauusd pair. I want same result in mt5 ea
Hey guys, I’ve been trading for 6 years now and I need to automate a strategy that is really simple and ove developed by myself. Can you help me on that? Here is my e-mail angelocherubini24@gmail.com
Hello Great Developer I am looking for a highly experienced MQL5 developer to build a production-grade Telegram to MT5 signal copier. Requirements: • <1 second execution latency (Telegram → MT5) • Intelligent signal parsing (layered entries, partial closes, BE, TP4 open trailing, modifications) • Multi-provider support (scalable to 100+) • Built-in advanced backtesting system • Configurable risk management settings •
What information would you need for Ninjatrader automated trading and approximately how long would it take ? Bill if anyone can give response here I will be glad to discuss
Khumza bot 30 - 40 USD
■Specification: Hello freelancers i need a bot.Bot requirements (MT5 EA -Extra Conservative).■Platform: MetaTrader 4/5 (PC and mobile compatible).■Markets:Forex Pairs(Gbpusd,Gbpjpy,Usdjpy),Us30,Gold,Bitcoin. ■Risk Profile(Very Conservative) ◇Risk 0.25% -0.5% per trade maximum.◇No martingale,no grid,no averaging down.◇One trade per symbol at a time. ◇Maximum 1-6 good trades per day.■STRATEGY LOGIC(All
Hello, Good programmer help in track of programmer in mql5 market sells product and give fake expert advisor see attached for name of programmer. NEEDS TO GIVE HIS CLIENT MONEY BACK OR PROVIDE THE REAL EXPERT ADVISOR Gold on the Go Experts Nguyen Hang Hai Ha Version: 1.1 Updated: 23 June 2025 Activations: 10 Expert Gold on the Go is the latest generation of automated trading robots programmed
Hello! I am looking for an experienced developer to build a robust, customizable Expert Advisor (MT4/MT5) or a standalone Python bot. The strategy is based on pure Price Action (Support & Resistance breakouts) on the XAUUSD (Gold) 30-Minute chart. It relies heavily on "human-like" chart analysis, such as looking left for targets, waiting for a price pullback (a "flip") before entering, and managing the trade based on
Acrylic-bot 30 - 800 USD
Creating this robot to help trade for you.It all about making profit. A robot that can change lives help people make profits. It’s not just a bot but the way to the future
I need very small modification in MQL4 code, details will be send for selected programmers. Source of code required. Thank you for your patience and attention, Have a nice day! I prefer programmers who will be accepting crypto payment on next project, so please write me in first message if you will be able to accept crypto in the future

Информация о проекте

Бюджет
10 - 30 USD