#property copyright "Copyright © 2009, Michael E Wilkinson DDS" #property link "mewddsltd@msn.com" #property show_inputs #include extern bool DeleteOpenLong.Profitable = FALSE; extern bool DeleteOpenLong.Losing = FALSE; extern bool DeleteOpenShort.Profitable = FALSE; extern bool DeleteOpenShort.Losing = FALSE; extern bool DeletePendingLong = FALSE; extern bool DeletePendingShort = FALSE; int AuthorizedDate() { bool li_ret_0; string ls_4 = "2009.12.31"; int l_str2time_12 = StrToTime(ls_4); if (TimeCurrent() <= l_str2time_12) li_ret_0 = TRUE; else li_ret_0 = FALSE; return (li_ret_0); } int AuthorizedAccount(int ai_0) { bool li_ret_4 = FALSE; if (ai_0 == 6025474 || ai_0 == 6048211 || ai_0 == 6048211 || ai_0 == 5569156 || ai_0 == 2088182226 || ai_0 == 2088203736 || ai_0 == 6046489 || ai_0 == 2368036 || ai_0 == 5661503 || ai_0 == 11201 || ai_0 == 1139824 || ai_0 == 6054916 || ai_0 == 5672146 || ai_0 == 6054298 || ai_0 == 6056548 || ai_0 == 2413999 || ai_0 == 1612010 || ai_0 == 1612012 || ai_0 == 1612015 || ai_0 == 1613288 || ai_0 == 1613289 || ai_0 == 1613290 || ai_0 == 1613292 || ai_0 == 1613293 || ai_0 == 1614331 || ai_0 == 5635503 || ai_0 == 2088200531) li_ret_4 = TRUE; else li_ret_4 = FALSE; return (li_ret_4); } int AuthorizedKey(int ai_0) { bool li_ret_4 = FALSE; int li_8 = 1 * StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 0, 2)); int li_12 = 3 * StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 2, 2)); int li_16 = 5 * StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 4, 2)); int li_20 = StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 6, 2)) * 2; int li_24 = StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 8, 2)) << 2; int li_28 = 6 * StrToInteger(StringSubstr(DoubleToStr(ai_0, 0), 10, 2)); int li_32 = li_8 + li_12 + li_16 + li_20 + li_24 + li_28; if (li_32 == 57 || li_32 == 61 || li_32 == 67 || li_32 == 76 || li_32 == 200 || li_32 == 204 || li_32 == 206 || li_32 == 211 || li_32 == 213 || li_32 == 225 || li_32 == 254 || li_32 == 311 || li_32 == 349 || li_32 == 354 || li_32 == 378 || li_32 == 383 || li_32 == 417 || li_32 == 456 || li_32 == 495 || li_32 == 514 || li_32 == 518 || li_32 == 522 || li_32 == 546 || li_32 == 576 || li_32 == 602 || li_32 == 689) li_ret_4 = TRUE; else li_ret_4 = FALSE; return (li_ret_4); } int start() { int l_pos_0; int l_mb_code_4; int l_mb_code_8; int l_mb_code_12; int l_mb_code_16; int l_mb_code_20; int l_mb_code_24; if (AuthorizedDate() && AuthorizedAccount(AccountNumber()) && AuthorizedKey(AccountNumber())) { l_pos_0 = 0; if (DeleteOpenLong.Profitable) { l_mb_code_4 = MessageBox("Are you sure you want to close all open buy orders that ARE profitable?", "Question", MB_YESNO|32|262144); if (l_mb_code_4 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_BUY && OrderProfit() > 0.0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, White); } } } } } if (DeleteOpenLong.Profitable) { l_mb_code_8 = MessageBox("Are you sure you want to close all open buy orders that ARE NOT profitable?", "Question", MB_YESNO|32|262144); if (l_mb_code_8 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_BUY && OrderProfit() < 0.0) OrderClose(OrderTicket(), OrderLots(), Bid, 3, White); } } } } } if (DeleteOpenShort.Profitable) { l_mb_code_12 = MessageBox("Are you sure you want to close all open sell orders that ARE profitable?", "Question", MB_YESNO|32|262144); if (l_mb_code_12 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_SELL && OrderProfit() > 0.0) OrderClose(OrderTicket(), OrderLots(), Ask, 3, White); } } } } } if (DeleteOpenShort.Losing) { l_mb_code_16 = MessageBox("Are you sure you want to close all open sell orders that ARE NOT profitable?", "Question", MB_YESNO|32|262144); if (l_mb_code_16 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_SELL && OrderProfit() < 0.0) OrderClose(OrderTicket(), OrderLots(), Ask, 3, White); } } } } } if (DeletePendingLong) { l_mb_code_20 = MessageBox("Are you sure you want to close all pending buy orders?", "Question", MB_YESNO|32|262144); if (l_mb_code_20 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT) OrderDelete(OrderTicket()); } } } } } if (DeletePendingShort) { l_mb_code_24 = MessageBox("Are you sure you want to close all pending sell orders?", "Question", MB_YESNO|32|262144); if (l_mb_code_24 == IDYES) { for (l_pos_0 = OrdersTotal() - 1; l_pos_0 >= 0; l_pos_0--) { if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol()) { RefreshRates(); if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket()); } } } } } return (0); } Alert("Use of this script is not authorized on this account!"); return (0); }