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 примеров
Похожие заказы
Hello! Objective Convert an existing MT4 Expert Advisor (MQL4) into MT5 (MQL5) with ABSOLUTELY IDENTICAL trading behavior . This is not a rewrite, enhancement, optimization, or refactor. This is a behavior-preserving port . If the MT5 version does anything different in live conditions, the job is considered failed . Core Requirement — Non-Negotiable The MT5 EA must produce the same results as the MT4 EA under
Specification Hi Free lancers, I need an EA which relates to Sure Fire Hedging EA base on Below parameters needed. Overview how it works: This EA will be able to open a trade with either Buy or Sell selection (manual- to be manually switch buy or sell selection ), another selection for automatic open trading can choose only buy. Once the EA already open trade (example -buy position) with starting lot size 0.01
Hedge Lot Plus EA Descriptions: (New EA) 1- The necessary explanations, documentation, and working principle details will be provided after the contract is signed. 2- The chart, button, and dashboard- template sample code will be provided. 3- There is no indicator. and work principle is easy. ** After the contract is signed,sampe code, a sample EA for "Hedge Lot Plus EA" and detailed information about the working
Experienced developer needed for a $100 project. I need to build three trading bots to copy signals from a Telegram channel and execute them on a trading account. The first bot will be used in the second and third bots as well, with some minor modifications. I will pay $40 for the first bot, $30 for the second, and $30 for the third. Contact me for details
1- Parts to Be Updated in Universal EA: 1- For Mode 2 (No Indicator Mode), a candle count parameter will be added for pivot breakout. The EA will determine how many candles after the pivot breakout it will add a position based on this parameter. 2- In Mode 1 (MA Mode), we will fix the error in one of the "Select Take Profit" modes called "Kill Position + Clean One by One." 3- We will fix the errors in Recovery Mode
I would manually draw one or more trendline or horizontal line in MT5. I would manually add description to each trendline or horizontal line for the desired action: Buy, Sell, Close buy orders, Close sell orders or Close all orders. When a candle touches the trendline or horizontal line, EA should execute the desired action. The desired action must be only once for a trendline or horizontal line. There should be some
Data Integrity 500 - 1000 USD
The trading bot is an automated software system designed to monitor financial markets, execute trades, and manage risk based on predefined strategies. The bot aims to maximize profits while minimizing human intervention and emotional decision-making. Scope: Supports automated trading on selected exchanges (e.g., Binance, Bitget, Coinbase). Executes trades based on technical indicators, signals, or AI models. Provides
1. General Objective Development of an Expert Advisor in MQL5 intended for Futures markets , based on an existing trading strategy that I will provide (described logic or precise rules). The main objectives are: Faithful implementation of the strategy , Full debugging of the EA, Validation of correct behavior through backtesting. 2. Markets and Instruments Markets: Futures Symbols: to be defined (e.g. indices
Subject: Major Upgrade Request: Auto Confluence of Signal/Trend/Momentum Scores with Multi-Timeframe SMC Hello, Your bot is excellent analytically, but I'm facing daily manual intervention due to the multiple indicators and timeframes. --- 📊 Current Situation: The bot uses: · Signal Score · Trend Score · Momentum Score · SMC Analysis · 3 Timeframes (Fast 5M, Medium 15M, Main 1H) · 4 Additional Indicators Currently
SMC Trading Bot 30 - 60 USD
1. The Core Idea: The "Liquidity-to-Liquidity" Engine Instead of just looking for a "Supply Zone," the bot must ask: "Whose money was just taken, and whose money are we targeting next?" The "Valid Move" Checklist A structure break or a zone is only "Real" if it meets the SMC Trinity: Inducement/Sweep: Price must take out a previous minor high/low (Retail Stop Loss) before the move. Displacement: The move must be

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

Бюджет
10 - 30 USD