Close all multi currency open orders and cancel pending orders according to various scenarios. Slippage for open orders is calculated for each currency. Choose only one scenario per visit, the script processes the first menu item selected.
#property copyright "Copyright © 2007, sx ted" #property show_confirm
#include <stdlib.mqh>
double Price[2]; int giSlippage;
void start() { int iOrders=OrdersTotal()-1, i; for(i=iOrders; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()<=OP_SELL) && GetMarketInfo() && !OrderClose(OrderTicket(),OrderLots(),Price[1-OrderType()],giSlippage)) OrderError(); } }
void OrderError() { int iError=GetLastError(); Print("Order:",OrderTicket()," GetLastError()=",iError," ",ErrorDescription(iError)); }
bool GetMarketInfo() { RefreshRates(); Price[0]=MarketInfo(OrderSymbol(),MODE_ASK); Price[1]=MarketInfo(OrderSymbol(),MODE_BID); double dPoint=MarketInfo(OrderSymbol(),MODE_POINT); if(dPoint==0) return(false); giSlippage=(Price[0]-Price[1])/dPoint; return(Price[0]>0.0 && Price[1]>0.0); }
|