Last order profit code please help!! - page 2

 
Dua Yong Rew:

Get the total profits of last xx trades


how to get the performance results on current day ?

server time from 0000 until current time

acc growth %, total pips, and also total profit amount.

 
prweza:

I just mean the profit of last  closed order.Not the sum of all closed orders.,


Yes. You can get the last profit of just one trade with my function. Just specify 1.

 
forextime8:

how to get the performance results on current day ?

server time from 0000 until current time

acc growth %, total pips, and also total profit amount.


I don't have this kind of function done in any of my ea therefore I have no code

 

analyze all historic orders and filter orderclosetime then pull OrderProfit() from the order(s) that was most recently closed.

 
nicholishen:



Thanks it works.

 
Dua Yong Rew:

Get the total profits of last xx trades

This will get the profits of xx trades, not the LAST xx trades since history not in order!!!, how could we do this pls somebody help!.


How to get profits of the LAST X trades.

 

Hi, I have written a function to check that if there is a loss in the last xx (let's say five) previous order and then if it is true when I call it in the EA, it increases the lot accordingly but it seems that it doesn't work properly so need your help. Here is the function:

bool CheckLoss(int Count)
  {
//----

   int      Cnt     = 0;
  
   static bool isLoss = false;

   for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false)
      {
         Print("Error in history!");

         break;
      }

      if(OrderSymbol() == _Symbol && OrderMagicNumber() == order_magic)
      {
        
        
            Cnt++;
            if (OrderProfit() < 0)
               isLoss = true;
            else
               isLoss = false;  
        
      }

      if(Cnt == Count) break;
   }


and here what I want to call it for my Moneymanagement

case MM_MARTINGALE: 
        
         if (CheckLoss(5) == true)
            volume = lots * 2;
         break;  

 
Ali Najafi:

Hi, I have written a function to check that if there is a loss in the last xx (let's say five) previous order and then if it is true when I call it in the EA, it increases the lot accordingly but it seems that it doesn't work properly so need your help. Here is the function:

bool CheckLoss(int Count)
  {
//----

   int      Cnt     = 0;
  
   static bool isLoss = false;

   for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false)
      {
         Print("Error in history!");

         break;
      }

      if(OrderSymbol() == _Symbol && OrderMagicNumber() == order_magic)
      {
        
        
            Cnt++;
            if (OrderProfit() < 0)
               isLoss = true;
            else
               isLoss = false;  
        
      }

      if(Cnt == Count) break;
   }


and here what I want to call it for my Moneymanagement

case MM_MARTINGALE: 
        
         if (CheckLoss(5) == true)
            volume = lots * 2;
         break;  



as first the script to gains return as referring finest of closed order as that gives with results of positive or negative.

the script to distinct list  as those might be of also one with cumulative or single returns from last order.

as follows with 

reference of next order to put on request with the indicator signal as preparing option.


the list might be of one as finest to gives with returns of string or integer value.

that those might be of one as fine to work as from switches with the script as collecting list from the running order as still opened or one or some as closed with the returns of positive, negative and more as scripts to put with the plus symbol on cummulating different returns from the list.

and one to put with the limitation as script to collects of spare with distance range as the order (open or closed as by request) to gives of results from different timeframe to collect list of population of order


the number on returns with the calculation of point on request might be distinct as one to differ with rest as per directive for the intensive of command as preparing the finest return of value.

 
palepalepale:

This will get the profits of xx trades, not the LAST xx trades since history not in order!!!, how could we do this pls somebody help!.


How to get profits of the LAST X trades.

the script must have with initiation as populating list on future use to work on reference as qualifying of one or different returns from the initial request on expecting list of results.

the return might be of one as the range on distance with the list on ranks to gives as order with the details on ext enumeration draws of some results of value.

and to compound as cumulating numbers of value as

the script might returning value on dollar unit on base or one as point following reference with request on scripts order.

...


as working with the martian gale theory 

trader might gives on decision as defining of one or some with different initial as the value on referring returns on contanct value that those have with the different qualification as disputing indication as expecting preset to put with the following shift of level with the higher stage on martian ale sterategy on running trade

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

    1. Do not assume history has only closed orders.
                OrderType() == 6, 7 in the history pool? - MQL4 programming forum

    2. Do not assume history is ordered by date, it's not.
                Could EA Really Live By Order_History Alone? (ubzen) - MQL4 programming forum

    3. Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
                "balance" orders in account history - Day Trading Techniques - MQL4 programming forum
      Broker History
      FXCM
      Commission - <TICKET>
      Rollover - <TICKET>

      >R/O - 1,000 EUR/USD @0.52

      #<ticket>  N/A
      OANDA
      Balance update
      Financing

  2. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11