Skip to content

Instantly share code, notes, and snippets.

@matthewkastor
Last active January 23, 2016 22:18
Show Gist options
  • Save matthewkastor/3b7aab61e515600f0e46 to your computer and use it in GitHub Desktop.
Save matthewkastor/3b7aab61e515600f0e46 to your computer and use it in GitHub Desktop.
function to close the currently selected order in metatrader 4
// bool result = CloseOpenOrder(5);
// closes the currently selected order
bool CloseOpenOrder(int slippage){
double price;
if(OrderType() == OP_SELL) {
price = Ask;
} else {
price = Bid;
}
bool closeResult = OrderClose(OrderTicket(),OrderLots(),price,slippage,clrYellow);
if(!closeResult){
Print(GetLastError());
}
return closeResult;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment