1. Function oldest long profit and oldest short profit / 2. count profit history buy / sell

MQL4 Consultation

Job finished

Execution time 2 minutes
Feedback from employee
Great customer. highly recommended!
Feedback from customer
good Job and fast.

Specification


1.

i would like the funkction to integrate it in my EA.

the Profit of the oldest open/pending Long-position

the Profit of the oldest open/pending short-position


something like that (that is for all positions)....:

//+------------------------------------------------------------------+
double countprofitBS(int mode,int order_type)
  {
   double profit=0;
   if(OrdersTotal()>0)
     {
      for(i=OrdersTotal()-1;i>=0;i--)
        {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()==Symbol() && OrderType()==order_type && OrderMagicNumber()==magic)
           {
            if(mode==0)profit=profit+(OrderClosePrice()-OrderOpenPrice())/pt;
            if(mode==1)profit=profit+OrderProfit()+OrderCommission()+OrderSwap();
           }
        }
     }
   return(profit);
  }


2.

and the function for Count Profit for buy / and sell positions

countprofit sell

Countprofit buy

something simaler like that:

// mode 0 = pips, mode 1 = dollars

double countprofit(int mode)
  {
   double profit=0;
   if(OrdersTotal()>0)
     {
      for(i=OrdersTotal()-1;i>=0;i--)
        {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==magic)
           {
            if(mode==0)profit=profit+(OrderClosePrice()-OrderOpenPrice())/pt;
            if(mode==1)profit=profit+OrderProfit()+OrderCommission()+OrderSwap();
           }
         if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==magic)
           {
            if(mode==0)profit=profit+(OrderOpenPrice()-OrderClosePrice())/pt;
            if(mode==1)profit=profit+OrderProfit()+OrderCommission()+OrderSwap();
           }
        }
      if(OrdersHistoryTotal()>0)
        {
         for(i=OrdersHistoryTotal()-1;i>=0;i--)
           {
            OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
            if(OrderOpenTime()<timex)break;
            if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==magic)
              {
               if(mode==0)profit=profit+(OrderClosePrice()-OrderOpenPrice())/pt;
               if(mode==1)profit=profit+OrderProfit()+OrderCommission()+OrderSwap();
              }
            if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==magic)
              {
               if(mode==0)profit=profit+(OrderOpenPrice()-OrderClosePrice())/pt;
               if(mode==1)profit=profit+OrderProfit()+OrderCommission()+OrderSwap();
              }
           }
        }
     }
   return(profit);
  }
  


Responded

1
Developer 1
Rating
(213)
Projects
246
45%
Arbitration
42
10% / 57%
Overdue
5
2%
Free
2
Developer 2
Rating
(590)
Projects
789
71%
Arbitration
9
33% / 33%
Overdue
22
3%
Free
Published: 8 codes
3
Developer 3
Rating
(365)
Projects
412
36%
Arbitration
35
26% / 57%
Overdue
63
15%
Free
4
Developer 4
Rating
(499)
Projects
744
56%
Arbitration
48
31% / 31%
Overdue
120
16%
Free
Published: 1 code
5
Developer 5
Rating
(574)
Projects
945
47%
Arbitration
309
58% / 27%
Overdue
125
13%
Free
6
Developer 6
Rating
(94)
Projects
148
59%
Arbitration
16
38% / 13%
Overdue
25
17%
Free
Published: 1 code
7
Developer 7
Rating
(885)
Projects
1410
67%
Arbitration
123
32% / 41%
Overdue
217
15%
Free
Published: 1 code
8
Developer 8
Rating
(1)
Projects
1
0%
Arbitration
0
Overdue
0
Free
9
Developer 9
Rating
(206)
Projects
333
35%
Arbitration
66
12% / 58%
Overdue
87
26%
Free
10
Developer 10
Rating
(33)
Projects
35
40%
Arbitration
11
9% / 91%
Overdue
4
11%
Free
Published: 4 codes
11
Developer 11
Rating
(4)
Projects
6
0%
Arbitration
2
0% / 50%
Overdue
4
67%
Free

Project information

Budget
30+ USD