Author: Verdi
Orders Execution
Checks for the total of closed orders
0 Views
0 Downloads
0 Favorites
Point
//+------------------------------------------------------------------+
//|                                                        Point.mq4 |
//|                                                            Verdi |
//|                                                  nemo811@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Verdi"
#property link      "nemo811@mail.ru"

int start()
  {
   int OrdClose=OrdClose_b();
   double PointProfit=PointProfit_b();
   double OrdPoint=NormalizeDouble(PointProfit/OrdClose,1);

   Alert ("Market-îðäåðîâ: ",OrdClose," øò.",
          "\nÎáùàÿ ïðèáûëü: ",PointProfit," ïï.",
          "\nÓäåëüíàÿ ïðèáûëü: ",OrdPoint," ïï./îðä.",
          "\nwww.mt4.ucoz.com");

   return(0);
  }
//+------------------------------------------------------------------+
double PointProfit_b()
 {
  int i;
  double OrdOpenPrice=0;
  double OrdClosePrice=0;
  double OrdPrice=0;
  double MarketPoint=0;
  double PointProfit=0;  
  string SMB;
    
  for(i=OrdersHistoryTotal()-1;i>=0;i--)
   {
    if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == true)
     {
      if(OrderType()==OP_BUY || OrderType()==OP_SELL)
       {
        if(OrdOpenPrice<OrderOpenPrice())
         {
          OrdOpenPrice=OrderOpenPrice();
         } 
        if(OrdClosePrice<OrderClosePrice())
         {
          OrdClosePrice=OrderClosePrice();
         } 
        if(OrderType()==OP_BUY) OrdPrice=OrdClosePrice-OrdOpenPrice;
        if(OrderType()==OP_SELL) OrdPrice=OrdOpenPrice-OrdClosePrice;
        SMB=OrderSymbol();
        MarketPoint=MarketInfo(SMB,MODE_POINT);
        PointProfit+=NormalizeDouble(OrdPrice/MarketPoint,0);
       }          
     }
    OrdOpenPrice=0;
    OrdClosePrice=0;
    OrdPrice=0; 
    MarketPoint=0;
   }
  return(PointProfit);
 }
 
int OrdClose_b()
 {
  int OrdClose=0;
  int i;
  for(i=OrdersHistoryTotal()-1;i>=0;i--)
   {
    if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) == true)
     {
      if(OrderType()==OP_BUY || OrderType()==OP_SELL)
       {
        OrdClose++;
       }          
     }
   }
  return(OrdClose);
 }

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 ---