Finally got back from my dev lol I investigated the problem. Indeed we know that the partial filling of reverse order may produce several deals like "out"; "out/in"; "in" instead of one deal of "out/in" type. Last release I'd corrected the version 5.5 so that it counts two types of deals: "out"; "out/in" (not only "out/in"). But April 17 we see the similar situation: the EA becomes "blind" for the [negative] profit of the "out" deal #22776861 BUY 4.0 ($-156.00) 08:33:32 (13:33:32). I find only one explanation: when broker exchanged the deal BUY 4.0 then that position (SELL 4.0) was fully finished by MT5 terminal's executing system. Then the terminal MT5 opened "new" position with new ID by the broker's technical deal #22776862 BUY 4.0. It's outrageously if it's indeed so. After all, in fact, this is the same position (in the conditions of netting-account), it's just subjected to a reverse. So that position must have the same position's ID. So now we must very complicate the EA by functions of connecting "different" sequental positions (with different positions' IDs) to correctly calculate the process' entire profit. It's necessary for correct target placing in conditions of "full" closure of some positions (zero-position producing) by partial filling of reverse STOP-orders. Basically it seems that if the netting results in zero net position, a new order ID is assigned that causes the algo to misprice the target. Hopefully it's the right fix this time
I'm not a programmer by profession, though I have studied and programmed in a variety of languages including Fortran, Pascal, FoxPro, C# and R. I took 2 Udemy courses in MQL5 in the summer of 2021 and in August I started paying my dues, learning the ins and outs of futures netting account trade management. My 1st EA, that worked perfectly in demo mode, went haywire in live trading. It somehow entered into a loop that cost me $535 in commissions and the spread, opening and immediately closing MNQ and M2K, all in a couple of seconds. More lessons, each of a different nature, followed. The only way to learn is through live trading.
Finally this bastard netted 10% return after 2 months. But Nasdaq OR has been pretty fucking dead lately