OrderClose() Not working Please Help.

 

Hello, I am trying to get my open orders to close based on the ticket number but my positions do not close in the strategy tester. I have attached my code below. Any help will be greatly appreciated. Thank you. 

<removed>


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2021.05.05
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.

You should also learn to use the styler so that your code is easier for others to read. Also remove excessive empty lines.


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.
 
  1. Use code button.
  2. Post in the correct place.
  3.     Sell = OrderClose(OrderTicket(),0.1,Ask,10,clrBlue);

    You can not use any Trade Functions until you first select an order.

 
William Roeder:
  1. Use code button.
  2. Post in the correct place.
  3. You can not use any Trade Functions until you first select an order.

Thank you, that fixed it!!

 
And a ticket is not a double.