Download MetaTrader 5
To add comments, please log in or register
Publish the program in the Market and sell it to millions of traders!
Dannoo007
195
Dannoo007 2015.10.21 10:43 

Hello forum,

So far I have this, below, but it counts ALL trades in history. How do I break the cycle so only the LAST CONSECUTIVE trades of same sign are counted - I have some (complicated) ideas but I feel there might be a a quick way? 

Many thanks in advance,

Dan.

int GainCount = 0; int LossCount = 0;
   for(int GainLossCnt = OrdersHistoryTotal()-1; GainLossCnt >=0; GainLossCnt--){
      if(OrderSelect(GainLossCnt,SELECT_BY_POS,MODE_HISTORY) && 
         OrderMagicNumber() == magic &&
         OrderSymbol() == symbol &&
         OrderProfit()>=0)
         GainCount++;
         
      if(OrderSelect(GainLossCnt,SELECT_BY_POS,MODE_HISTORY) && 
         OrderMagicNumber() == magic &&
         OrderSymbol() == symbol &&
         OrderProfit()< 0)
         LossCount++;
         
      }
Keith Watford
Moderator
8017
Keith Watford 2015.10.21 11:38  
Dannoo007:

Hello forum,

So far I have this, below, but it counts ALL trades in history. How do I break the cycle so only the LAST CONSECUTIVE trades of same sign are counted - I have some (complicated) ideas but I feel there might be a a quick way? 

Many thanks in advance,

Dan.


First step is to define what you mean by consecutive. Consecutive by open time or by close time
Dannoo007
195
Dannoo007 2015.10.21 12:36  
GumRai:
First step is to define what you mean by consecutive. Consecutive by open time or by close time
  Consecutive closed orders, of same sign. There is only one EA, opening 1 order at a time.
/
To add comments, please log in or register