- Moving Stop to Breakeven works in backtest but not Live
- Automatic moving Stoploss in EA
- Kurka Trader - GREEDY BS
Please re-edit your post and place your code properly by using the "</>" icon from the posting toolbar or use Alt+S. Use proper styling, by using MetaEditor's Styler functionality.
Also, explain in detail what are the problems that you are facing and what do you expect your code to do (that it is not doing). Post also the log output of any errors it reports.
Do not double post!
I have deleted your duplicate topic.
Post code properly as Fernando has already said.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Also, make sure your code sample can be compiled (without errors or warnings) and that it is self-contained and can be tested as is, otherwise we will not be able test and debug it on our end if needed.
if(ticket>=0) return true;
What is the purpose of this?
What do you think it does?
Then your trailing stop code will not work! If you call the function "trailingstop_check_order" with a valid ticket number (which is greater than 0), for an obviously open order, and then return from the function because it is valid, then nothing more will be done by the function. What is the logic of that?
Also, instead of using Bid or Ask for calculating the trailing stop, consider using the orders current closing price "OrderClosePrice()".
That way, you can combine the Buy and Sell logic into a single logic by using +ve or -ve to represent the direction in the calculations, making your code more robust without having to duplicate logic in reverse order for the two types.
Then your trailing stop code will not work! If you call the function "trailingstop_check_order" with a valid ticket number (which is greater than 0), for an obviously open order, and then return from the function because it is valid, then nothing more will be done by the function. What is the logic of that?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use