النتائج 1 إلى 2 من 2
الموضوع: اريد تصحيح هدا الكود من فضلكم
- 06-07-2023, 12:44 AM #1
اريد تصحيح هدا الكود من فضلكم
هدا الاكسبريت يقوم بمراقبة الصفقات المعلقة . في حال تفعيل احدي هده الصفقات يقوم تلقايا بعمل الغاى لجميع الصفقات المعلقة المتبيقة.
كود:// Input parameters input int MagicNumber = 12345; // Magic number to identify the orders // Global variables bool ordersExecuted = false; // Flag to check if orders have been executed // Initialize function void OnInit() { { // Subscribe to trade events EventSetTimer(OnTimer); // Set timer to check for executed orders } } // Timer event handler void OnTimer() { if (ordersExecuted) { // Cancel all pending orders for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) { if (OrderMagicNumber() == MagicNumber) { OrderDelete(OrderTicket()); } } } } ordersExecuted = false; // Reset the flag } } // Trade event handler void OnTrade() { if (ordersExecuted) return; // Ignore additional trade events if orders have already been executed for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) { if (OrderMagicNumber() == MagicNumber) { ordersExecuted = true; // Set the flag to true if an order is executed break: } } } } }
- 06-07-2023, 01:18 AM #2كود:
// Input parameters input int MagicNumber = 12345; // Magic number to identify the orders // Global variables bool ordersExecuted = false; // Flag to check if orders have been executed // Initialize function void OnInit() { { // Subscribe to trade events EventSetTimer(1); // Set timer to check for executed orders } } // Timer event handler void OnTimer() { if (ordersExecuted) { // Cancel all pending orders for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT || OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) { if (OrderMagicNumber() == MagicNumber) { bool delord=OrderDelete(OrderTicket()); } } } } ordersExecuted = false; // Reset the flag } } // Trade event handler void OnTrade() { if (ordersExecuted) return; // Ignore additional trade events if orders have already been executed for (int i = OrdersTotal() - 1; i >= 0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderType() == OP_BUY || OrderType() == OP_SELL) { if (OrderMagicNumber() == MagicNumber) { ordersExecuted = true; // Set the flag to true if an order is executed break; } } } } }