Author: Copyright � 2011, www.FxAutomated.com
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Wipeout
//+------------------------------------------------------------------+
//|                                                      Wipeout.mq4 |
//|                            Copyright © 2011, www.FxAutomated.com |
//|                                       http://www.FxAutomated.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, www.FxAutomated.com"
#property link      "http://www.FxAutomated.com"

//---- input parameters
extern string    Product="Wipeout v1";
extern double    CloseAllWhenProfitIs=300;
extern int       Slippage=5;
extern string    MoreAvailableAt="www.FxAutomated.com";
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

int start()
  {
//----
int StopMultd;
 int digits=MarketInfo("EURUSD",MODE_DIGITS);
if(digits==5){StopMultd=10;} else{StopMultd=1;}
int Slip=Slippage*StopMultd;
double CurrentProfit=NormalizeDouble(AccountEquity()-AccountBalance(),Digits);
  
if(CurrentProfit>=CloseAllWhenProfitIs){ // start check
 if(OrdersTotal()>0){
  for(int i=1; i<=OrdersTotal(); i++)          // Cycle searching in orders
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
        {
           if(OrderType()==OP_BUY){OrderClose(OrderTicket(),OrderLots(),Bid,Slip,CLR_NONE);}
           if(OrderType()==OP_SELL){OrderClose(OrderTicket(),OrderLots(),Ask,Slip,CLR_NONE);}
           
           int Error=GetLastError();
           if(Error>0){
           if(Error==2){Alert("Common error.");}
           if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); RefreshRates();}

           }
        }
     }
 }
}// start check   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---