Initial commit: MQL5 Scripts Collection (MetaTrader 5)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# 🚀 Unlock the Power of Trading!
|
||||
|
||||
Welcome to this open-source trading project. Here you will find powerful tools to enhance your trading journey. If you find this project useful, please consider starring ⭐, sharing, or donating to support further development!
|
||||
|
||||
---
|
||||
|
||||
**Support the project:**
|
||||
- Star this repository on GitHub
|
||||
- Share it with your trading friends
|
||||
- [Donate here](https://www.paypal.com/donate/?hosted_button_id=YOUR_BUTTON_ID) to help us grow!
|
||||
|
||||
---
|
||||

|
||||
|
||||
## Source Files
|
||||
- `oncecancelotherscript.mq5`
|
||||
|
||||
---
|
||||
> Made with ❤️ for the trading community.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,71 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| OnceCancelOtherScript.mq5 |
|
||||
//| Copyright 2012, Rone. |
|
||||
//| rone.sergey@gmail.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2012, Rone."
|
||||
#property link "rone.sergey@gmail.com"
|
||||
#property version "1.00"
|
||||
#property description "One Cancel Other(s) Script"
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
#include <Trade\Trade.mqh>
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
bool end = false;
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
int symbolOrders() {
|
||||
int total = OrdersTotal();
|
||||
|
||||
if ( total == 0 ) {
|
||||
return(0);
|
||||
}
|
||||
//---
|
||||
int symTotal = 0;
|
||||
for ( int i = 0; i < total; i++ ) {
|
||||
ulong ticket;
|
||||
|
||||
if ( (ticket = OrderGetTicket(i)) > 0 ) {
|
||||
if ( OrderGetString(ORDER_SYMBOL) == _Symbol ) {
|
||||
symTotal += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
return(symTotal);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Script program start function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnStart() {
|
||||
//---
|
||||
for ( ; !IsStopped() && !end; ) {
|
||||
if ( PositionSelect(_Symbol) ) {
|
||||
int total = OrdersTotal();
|
||||
|
||||
for ( int i = 0; i < total; i++ ) {
|
||||
ulong ticket;
|
||||
|
||||
if ( (ticket = OrderGetTicket(i)) > 0 ) {
|
||||
if ( OrderGetString(ORDER_SYMBOL) == _Symbol ) {
|
||||
CTrade trade;
|
||||
|
||||
ResetLastError();
|
||||
if ( !trade.OrderDelete(ticket) ) {
|
||||
Print("OrderDelete of ", ticket, " is failed. Error #", GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( symbolOrders() == 0 ) {
|
||||
end = true;
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Reference in New Issue
Block a user