counting last consecutive gains /or losses

Back to topics list To post a new topic, please log in or register
avatar
56
Dannoo007 2015.10.21 12: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++;
         
      }


avatar
Moderator
3427
GumRai 2015.10.21 13: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
avatar
56
Dannoo007 2015.10.21 14: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.
Back to topics list  

To add comments, please log in or register