My Trailing stop does not work (MQL5)
Can't say from what you have posted - put breakpoints just after the Trade.Position.Modify() calls and see what is written in the journal when it fails.
That should provide a clue
-
int cnt_B = CopyBuffer(Handle,Handle_Buy,0,3,BufferBuy); int cnt_S = CopyBuffer(Handle,Handle_Sell,0,3,BufferSell);
You haven't set the arrays as-series before populating them. - Why is the new bar code in the middle of OnTick, instead of being the first thing?
-
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)
And this is my expert code: