The above code sometimes nails it, sometimes doesn't. Maybe works right like 90 per cent of times or so. Sometimes misses the right moment, yet then later I'm lucky and the order comes back to profit and it executes the trailing stop correctly. This really sets me off and can potentially lead to great loss. I want it to automatically set the trailing stop at the precise exact moment when there is actual real profit; as in when after you subtract the commissions and swaps the order profit is still greater (by anything really ill take a cent even for my scalping strategy) and updating your account balance positively correctly.

Lag seems to prevent it from doing it right all the time. Convinced I must be wrong and there might be a much better way to do this so that I don't end up placing the trailing profit at below the actual real profit point.

Have tried various EAs and none seems to do this the way I wanted, as I have explained. This is the closest Ive gotten to it and it still misses sometimes.

1. Is it just the lag at the super tight stop level I'm going for?

2. How do I improve this code? How do I get the Trailing Stop to correctly trigger all the time at the exact point where there is a real profit made (after the commissions and swap charges)?

For sell orders, stops are relative to the Ask. If you could move it there, the order would close immediately. For Buy orders, relative to the Bid. Bogus call.

Lag is irrelevant.

Thanks a ton, I really appreciate your time into helping me fix this issue.

Ill enumerate my answers to your points for clarification

In answers to your points :

1. How exactly do I fix this code so as to achieve my desired result? What do I put there to reach my goal of having the trailing stop trigger
at the exact point where there is real profit after subtracting
commissions and swap?

The previous posted code and the following new attempt with what I could interpret from your advice return error 1 no matter what I try.

Tried changing the highlighted 0 you suggested to OrderOpenPrice(); so as to *not* have MQL interpret that I am "trying to change" any open price, yet this still yields the same error 1 code. I thought the value which you have highlighted, the 0 in the order modify in the price field, would have MQL interpret that I'm not trying to change anything. Error codes from https://book.mql4.com/appendix/errors just say that

ERR_NO_RESULT

1

No error returned, but the result is unknown.

Where do I go from here?

My logical thought about it was that if its the same symbol, the same order type, and the order profit is greater than order commissions+swaps, then proceed to modify the selected Order, not change the price, change the Stop Loss to current Ask (where theres already real profit after broker subtractions), not change the take profit, and not change any expiration or arrows. How is this wrong?

2. How would I have to change this code so that it does not yield error 1? Im just using

Alert(OrderTicket(), " ", GetLastError() );

in order to find out the "return codes" via checking the last error. Is this correct? The links you provided just tell you to try "! < code>" to check the return values for bools, and GetLastError() for ints. Im a little confused, do you mean the error or the return value of functions? How exactly do I check the exact return values themselves?

3. I'm lucky my broker does not have an issue with stops anywhere.

4.That was in the know from beforehand

5. Really glad lag is not relevant yet it sounds too good to be true; are you 100 per cent positively sure that on working cable (just got upgraded and its usually steady around the 60mbps, will prolly get VPS after Im done code) lag will never ever be an issue for this trailing stop after real profit situation though? Ever? Not even a single cent?

For sell orders, stops are relative to the Ask. If you could move it there, the order would close immediately. For Buy orders, relative to the Bid. Bogus call.

Lag is irrelevant.

Bah, had some wrong parameter count in the code. Added clrNONE, no more error code. What do I do with the price field and others to leave them untouched though? Progress.

OrderModify(OrderTicket(),OrderOpenPrice(),Ask,0,0,clrNONE);

?

So we can use NULL, clrNONE, and 0 to denote no changes in certain specific cases only? How do I know when to use 0 and when to use NULL? Ive even seen " " used sometimes to denote empty field/no change.NULL doesnt work to denote no change in every case? Id like my code to be as minimalistic/less byte consuming as possible so I thought using NULL everywhere would remove lag. So where can I use it and when not? Does it really save bytes at all anyway?

Void Type and NULL Constant

Syntactically the void
type is a fundamental type along with types of char, uchar, bool,
short, ushort, int, uint, color, long, ulong, datetime, float, double
and string. This type is used either to indicate that the function does
not return any value, or as a function parameter it denotes the absence
of parameters.

/////////////////

NULL only for void ones? Only for strings ?

https://docs.mql4.com/trading/ordersend

States it can be used in the int function OrderSend().

Why can't I put NULL everywhere to be as minimalistic as possible then?

Still the issue of the below real profit, heres a screen. Seems more keen code, yet same problem happened. Any ideas how to make it snappier so it never misses a cent and always gets profit above the subtractions?