- Need help on stopping EA to open another trade.
- Is there proof of profit from using Autotrading?
- Competition. I will write an expert for free.
>> 2. If any of the buy stop orders has become buy order and has closed at stop loss (bool condition)
if you want to do this, then correct me if i am wrong, dont you need to also check that there is a buystop open first -- before you check that the buy order has closed?
>> 2. If any of the buy stop orders has become buy order and has closed at stop loss (bool condition)
if you want to do this, then correct me if i am wrong, dont you need to also check that there is a buystop open first -- before you check that the buy order has closed?
Yes, you're very right, I have a different function that places the sell order and the buy stop orders, the function is not included in the file attached, it is a different file, because I want to have a separate function to manage buy stop orders I will just call the function immediately after the function that places the buy stop orders. I think you understand. Thanks
how can we help you if you do not include your full code? we do not know your logic if you do not include your full file.
Only thing that i can suggest is to use freelance service, or upload full file so we can analyse your full code.
how can we help you if you do not include your full code? we do not know your logic if you do not include your full file.
Only thing that i can suggest is to use freelance service, or upload full file so we can analyse your full code.
I have already replaced your attachments on two of your posts.
Please attach the source file directly, not a ZIP archive of the source file.
Then I suggest you please use the Freelance section. We are not here at your beck and call.

- 2023.12.13
- www.mql5.com
- Jonathan Olalekan Toyese: The function does not work kindly help me check what is wrong. Thanks
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) Your code if (sellCount < maxSellPositions) return True; else return False;
Simplified return sellCount < maxSellPositions;
-
bool IsNewCandleSell(){ static int BarsOnChart = Bars; if(Bars == BarsOnChart) return (false); BarsOnChart = Bars; return(true);
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
MT4: New candle - MQL4 programming forum #3 (2014)
MT5: Accessing variables - MQL4 programming forum #3 (2022)I disagree with making a new bar function, because it can only be called once per tick (second call returns false). A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011) -
int buyStopCounter = 0; if (OrdersTotal() > 0) { for (int i = OrdersTotal() - 1; i >= 0; i--) {
The if statement is unnecessary.
-
// Function to check if a sell order is still open bool IsSellOrderOpen() { int totalOrders = OrdersHistoryTotal(); for (int i = totalOrders - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderType() == OP_SELL && OrderSymbol() == Symbol()) { return true; // Found an open sell order
Your looking at history. That has nothing to do with checking for open orders. -
void ReplaceBuyStopOrder(int buyOrderTicket) { // Retrieve entry price and stop loss from the closed buy order double entryPrice = OrderOpenPrice(); double stopLoss = OrderStopLoss();
MT4: You can not use any Trade Functions until you first select an order.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use