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

Experts Libraries

Job finished

Execution time 11 days
Feedback from customer
_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!

Specification

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 !


Responded

1
Developer 1
Rating
(473)
Projects
1138
44%
Arbitration
51
31% / 33%
Overdue
500
44%
Free
2
Developer 2
Rating
(187)
Projects
367
56%
Arbitration
45
22% / 56%
Overdue
188
51%
Free
Published: 1 article, 6 codes
3
Developer 3
Rating
(24)
Projects
98
83%
Arbitration
4
0% / 25%
Overdue
9
9%
Free
Published: 6 codes
Similar orders
🔹 1. Core features (must have) Multi-account connection: MT5, can run many different brokers with different suffixes Real-time order copy: When the master opens/cuts/edits the order → the follower matches exactly. Low latency (the closer to 0 seconds the better). Customize copy volume: Fixed lot (fixed volume). Proportional lot (by % of capital). Multiplier (multiplier). Copy by order type: Choose to copy Buy/Sell
Pocket option bot 50 - 100 USD
I want a developer that can build a pocket option bot, You can only send application if you are experienced pocket option bot developer The bot should be develop base on my details that I will provided to the person that send application Best Regard
🔹 Job Offer: MQL5 Developer Needed for Prop Firm Challenge MT5 EA (US30 / GER40) I am looking for an experienced MQL5 programmer to build a high-performance trading bot for MT5, designed to pass prop firm challenges with selected providers. The EA should be focused on index trading , specifically US30 (Dow Jones) and GER40 (DAX) . Requirements: Proven expertise in MQL5 and algorithmic trading Development of a fast
Hello, good day to you Developers, I am looking for someone that can deliver on a project with the following requirements: The job I am about to give out will involve "Tradingview" and "cTrader" Tradingview: for analysis, as the Strategy uses one second charts/candles, cTrader: for executing and managing the trades. - For this cBot to work well for the project's aims, SPEED of execution is of upmost importance. - The
Job Description: · I am looking for an experienced MQL4 developer to create a high-speed scalping EA for US30 and DE40. The EA must be optimized for ultra-fast execution and should not rely on any indicators—only price action and pending orders (Buy Stop & Sell Stop). · I have written a complete and detailed documentation outlining the logic, execution flow, risk management, and required settings
The following Logic should be created example entryprice 3000 SL in the beginning 2996 Price reaches Entrpy oint = 3000 nothing happens Price reaches Entry point +NowTrailingSL_value(=2.0) price is then 3002 SL is moved to = 3000.20 ( is 3000+ 0.20) Price reaches Entry point +TopOnNowTrailingStoplossValue(=4.0) price is then 3004 SL is still 3000.20 Nothing happens Price reaches Entry point
I 'm contacting you because I'm currently managing an Excel project that centralizes the results monitoring of my trading accounts and the technical characteristics of my Expert Advisors (EAs) . The current system consists of several linked spreadsheets where : • Trading data is automatically uploaded from FXBlue/CSV • Key metrics are consolidated (Win Rate, Profit Factor, Expectancy, SQN, Drawdown, MAR , etc.) •
Looking for an EA that has been previously tested and can pass prop firm challenges. You will need to demonstrate the EA to showcase true nature. Please only apply if you have a system ready. This can be a previous job you already done for someone or have something in the files
Mthizo trades 30 - 200 USD
- *Currency Pairs*: Major pairs such as EUR/USD, XAU/USD and GBP/USD - *Funding Currency*: South African Rand (ZAR) - *Initial Deposit*: R100 (may require additional deposit for live trading) - *Risk Management*: Basic risk management features, such as stop loss and take profit - *Strategy*: Pre-defined strategy based on Smart Money Concept principles - *Cost*: Approximately R100-R200 (one-time cost or
I am interested in purchasing a ready-made automated EA (Expert Advisor) that is already tested and profitable. My key requirements are: Consistent profits with proven results (backtests and/or live performance) Low to medium risk, not overly aggressive Works on major forex pairs, indices, or gold Ready to use with minimal setup If you have an EA that meets these criteria, please share details, performance records

Project information

Budget
10 - 30 USD
VAT (19%): 1.9 - 5.7 USD
Total: 11.9 - 35.7 USD
For the developer
9 - 27 USD