Last active
January 23, 2016 22:18
-
-
Save matthewkastor/3b7aab61e515600f0e46 to your computer and use it in GitHub Desktop.
function to close the currently selected order in metatrader 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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