Update my simple EA to fix “invalid pointer access”, ensure reliable trade opening, and restrict maximum number of trades per signal

Job finished

Execution time 6 days
Feedback from customer
Paul is the best developer I have ever worked with. He is extremely attentive to details, very patient, and super helpful and responsive. He completed the project on time. I highly recommend him.
Feedback from employee
Great client to work with. Quick communication.

Specification

My current EA (I will refer to it as OP) opens opposite pending orders based on existing open trades in the terminal.


Example of how OP works:

1) Let's say I manually or automatically (through a different EA) open a buy trade for EURUSD with open price of 1.10000, SL of 1.00000, and TP of 1.20000

(magic number is 100, order comment is "euro breakout", and symbol is of course EURUSD)


2) OP will then identify open trades to act on based on magic number, order comment, or symbol. There are three different entry fields in the settings, for the user to type in the magic number, order comment, or symbol of the open trade that they want OP to identify and base its trade on. For this example, we will put EURUSD into the "symbol" field, so that OP looks for an open EURUSD trade in the terminal. 


3) OP identifies the open EURUSD buy trade (Trade A), and places a pending order in the opposite direction (Trade B) with an entry price at X% of the SL level of Trade A. For example, if the entry price setting is 0.65, then the entry price of Trade B would be at 65% of the distance between the entry price for Trade A (1.10000) and the SL for Trade A (1.00000). So in this example, the entry price of Trade B (EURUSD sell trade) would be 1.06500.


4) The order for Trade B is automatically canceled if it is not yet filled by the time Trade A is closed. In other words, the closure of Trade A causes the cancellation of the pending order for Trade B.


5) in the settings for OP, the user can customize the Volume, SL, TP, and Trailing Stop on Profit for Trade B


What I need modified, your key actions highlighted in bold:


1) When OP gets a signal to open an order, I am getting the following error: “invalid pointer access in ‘OP.MT5’ (128,16)”. The pending order fails to open, and OP removes itself from the chart it is attached to. Fix this error so that the order for Trade B is always successfully placed.


2) Limit the maximum number of Trade B orders to one per each Trade A

Continuing on the previous example, if I set the entry price percentage for Trade B at 0.4, OP will place a pending order for EURUSD sell at 1.04000. The user has set the SL and TP for Trade B at 4000 points (1.08000) and 4000 points (1.00000), respectively. If Trade B is filled, and then the price goes up to 1.08000, it hits SL and Trade B is closes. But then another pending order is placed with entry price of 1.04000, because Trade A is still open (until it hits its own SL or TP of 1.00000 or 1.20000), and OP is still looking to open a new Trade B based on any existing trade that fits the linkage (symbol EURUSD). So if the price goes up to 1.08000, hits Trade B SL, and then quickly goes back down to 1.04000, without ever touching the SL or TP for Trade A, then another Trade B is opened at the price of 1.04000.

This means that one Trade A can have multiple Trade Bs, which is not good. The code should be fixed such that for each Trade A, there is maximum one deal for Trade B, until Trade A is closed.


3) Ensure that a Trade B is filled even if Trade A opens and closes in a loss very quickly 

For example, if Trade A has a tight SL or if market movements are very strong and fast, Trade A can open and close in a loss in 1 second or less, not giving enough time for the pending order for Trade B to be opened and filled before being cancelled due to Trade A being closed. I believe the way the logic is now, the pending order for Trade B is automatically closed if it is not filled by the time Trade A is closed, regardless of whether Trade A closed in profit or in loss. The code should be fixed such that the pending order for Trade B is only cancelled if Trade A closes in profit.

And sometimes the issue may be that OP does not have enough time to place the pending order for Trade B by the time Trade A closes (due to slow server speeds, etc.) The code should ensure that there is always a filled order for Trade B if Trade A hits SL and closes in loss. This may require adding a “safety net” in the code so that if Trade A closes in loss before the pending order for Trade B can be placed, OP will immediately open a market order instead. The priority is to always open Trade B with pending orders, but in the rare cases that fails due to extremely fast Trade A closure, only then should a market order be used to open Trade B.


4) Ensure that once Trade B is filled, it is no longer affected by Trade A. Review the code to ensure that any actions with Trade A have no impact on Trade B once Trade B is already filled.


5) Ensure that the SL and TP of Trade B are modified based on the actual fill price after slippage. For example, if the entry price for Trade B is 1.04000 but it actually fills at 1.03800 due to slippage, ensure that the SL and TP are adjusted to be based on the actual fill price. So if the user settings for Trade B’s SL and TP are 1000 points, then the SL and TP of Trade B should be 1.04800 and 1.02800 instead of 1.05000 and 1.03000, because even though the pending order had an entry price of 1.04000, the actual fill price after slippage was 1.03800.


6) Add option to determine the lot volume of Trade B based on a percentage of the lot volume of Trade A. Insert code that will create a user input to calculate Trade B lot volume as a percentage of the lot volume of Trade A (for example 0.10 for 10%, 2.00 for 200%, 3.55 for 355%). So if the user setting for this 1.5, and Trade A has a volume 0.1 lots, then Trade B will have a volume of 0.15 lots. The code should ensure that Trade B lot is rounded up to the broker minimum lot. This input should only be active if the user input for fixed lot volume is 0.


7) Overall review of the code to identify and fix errors and optimize the speed of execution.


Files:

ZIP
OP.zip
2.3 Kb

Responded

1
Developer 1
Rating
(8)
Projects
11
0%
Arbitration
3
67% / 33%
Overdue
2
18%
Free
2
Developer 2
Rating
(41)
Projects
58
21%
Arbitration
3
67% / 0%
Overdue
9
16%
Loaded
3
Developer 3
Rating
(3)
Projects
4
0%
Arbitration
2
0% / 100%
Overdue
1
25%
Free
4
Developer 4
Rating
(7)
Projects
12
8%
Arbitration
2
0% / 50%
Overdue
4
33%
Free
5
Developer 5
Rating
(15)
Projects
34
24%
Arbitration
3
0% / 33%
Overdue
2
6%
Working
6
Developer 6
Rating
(574)
Projects
945
47%
Arbitration
303
59% / 25%
Overdue
125
13%
Free
Similar orders
Hey, I have an expert advisor that does very active, would be glad to have expert checking the whole EA logic, check the entire code to better understand the core strategy logic, then run thorough backtesting with the best possible settings and able to optimize the EA for an optimal trading performance and also create a suitable set file based backtesting report and optimization, applicant must be very reliable with
The EA will have 3 moving average and trade are executed upon cross over.The EA will finally be in MQL4 and MQL5. The EA will also be protected with a password. Further description will be given after agreement
Technical Skills: - Programming Languages: Proficiency in low-latency programming languages like C++ is crucial for developing high-speed trading algorithms. - Algorithmic Trading: Experience with algorithmic trading strategies, including market making, statistical arbitrage, and trend following. - Market Data Analysis: Ability to analyze large datasets and extract meaningful insights to inform trading decisions
I need a trading robot expert advisors/EA on MQL5. With the following strategies. Trend Following and Mean Reversion/Scalping and Range Trading* 1. *Trend Following and Mean Reversion*: Capture trends and profit from mean reversion opportunities. 2. *Scalping and Range Trading*: Profit from short-term price movements and range-bound opportunities. *Trend Following and Mean Reversion* - *Indicators:* - Moving
Hi guys Does anyone have experience with K-Means and MQL5? I would like to get an include file which I can use in my EAs. I would need to work with an ML Engineer who has deep understanding with K-Means. The include file should be used for regime detection. I can drop more information about my EA once I see that you qualify for the job :-) Cheers
READ CAREFULLY And if you have done 50 projects before then apply others i will reject SEPARATE LOGIC MUST BE SEPARATE AND ALL INPUTS MUST BE VISIBLE WITH FALSE TRUE OPTION TO ON OFF FUNCTION 🔺 BUY Signal (Boom Market) ✅ Pattern Formation (Spike-Based Buy Setup) First Spike : Large bullish spike candle . Mitigation Candle : Small bearish candle inside or partially inside the bullish spike. Second Spike
Job Description I am looking for a highly skilled MQL5 DEVELOPER and A TRADER to work on an MT5 Expert Advisor (EA) project. The main tasks will include: 1. Code Compilation & Optimization – Reviewing, compiling, and streamlining the existing EA code to ensure efficiency and stability. 2. Backtesting Setup & Execution – Running professional backtests to ensure the EA produces consistent, gradual profit growth curves
Hello I need a professional developer to code my indicator with my strategy and settings for TradingView I have specific requirements, how i want my bot settings to be, i have a video explanation for all the requirements after programming. I'm going to connect it with a bridge and a webhook Contact me only if you can handle it, and you know about TradingView, it's a complex code with a little budget, but I will
My Strategy is complex and requires a deep understnading of the market and coding knowledge. DO NOT MESSAGE IF YOU DONT HAVE THESE 2 THINGS. I will give more details of strategy during message. Pleasure doing business
Hello, I would like to develop a custom Expert Advisor (EA) for MT4 (or MT5 if preferred). Requirements: Open trades based on a signal (to be specified later: e.g., indicator, moving average cross, or manual conditions). Automatically set Stop Loss (SL) and Take Profit (TP) for each trade. Option to open an averaging/hedging trade with the same lot size when the price moves against the first trade by a defined number

Project information

Budget
30+ USD
For the developer
27 USD
Deadline
to 4 day(s)