View Single Post
  #20 (permalink)  
Old 12-12-2006, 12:14 PM
european's Avatar
european european is offline
Senior Member
 
Join Date: Apr 2006
Posts: 282
european is on a distinguished road
Here's my code that i wrote long time ago, it will close all running positions.



#include <stdlib.mqh>
#include <WinUser32.mqh>
int start()
{
double sA;
int cnt, totalOrders;
totalOrders = OrdersTotal();

if (totalOrders>0)
{
for (cnt=0;cnt<totalOrders;cnt++)
{
OrderSelect(0, SELECT_BY_POS);
if (OrderType() == OP_BUY) sA = MarketInfo(OrderSymbol(),MODE_BID);
else sA = MarketInfo(OrderSymbol(),MODE_ASK);
OrderClose(OrderTicket(),OrderLots(),sA,3,CLR_NONE );
}
}
return(0);
}

Last edited by european; 12-12-2006 at 12:34 PM.
Reply With Quote