What is wrong in my trailing stop code at my expert?
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)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
And this is my expert code: