Skip to content

Instantly share code, notes, and snippets.

@currencysecrets
Created April 17, 2013 01:40
Show Gist options
  • Save currencysecrets/5401139 to your computer and use it in GitHub Desktop.
Save currencysecrets/5401139 to your computer and use it in GitHub Desktop.
Removing pending orders when they do not match the new trading system's version number. It does assume that the system tag is placed in the OrderComment area of a new order.
void removeOldOrders( string sym, string systemTag ) {
int tot = OrdersTotal();
for( int i = 0; i < tot; i++ ) {
if ( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) {
if ( OrderSymbol() == sym ) {
if ( OrderType() != OP_BUY || OrderType() != OP_SELL ) {
if ( OrderComment() != systemTag ) { // don't forget your new order must contain the systemTag!
OrderDelete( OrderTicket() );
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment