Some helps would be appreciated, for understanding the logic.

 

Hi everybody, 

I try to create a little money management logic but big in complexity, i searched everywhere, tested couple of things, but nothing now i'm empty.

Maybe i don't found the logic behind it, i explain:

i want to say that,

if it's profit and history consecutivelosses was > 1

then nextlot = all consecutivelosses * multiplier.


i created a function, and a little pat of the MM code: they are here:


//+----------------------------------------------------------------------+
//|--COUNT FUNCTION                                                      |
//+----------------------------------------------------------------------+
void Count(int &count)
  {
   count = 0;
   HistorySelect(0, TimeCurrent());
   int total = HistoryDealsTotal();
   ulong ticket = 0;
   //----------------------------LOOP FOR:
   for(int i = total-1; i >= 0; i--)
     {
      if((ticket = HistoryDealGetTicket(i)) <= 0) continue;
      if(HistoryDealGetString(ticket, DEAL_SYMBOL) == Symbol()
      && HistoryDealGetInteger(ticket, DEAL_TYPE) <= 1 
      && HistoryDealGetInteger(ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT)
       {
         if(HistoryDealGetDouble(ticket, DEAL_PROFIT) > 0)   
            break;
         count++;                
       } 
     }
   return;
  }  


And the MM that goes with the function: it's not over i was testing but 


//+----------------------------------------+     
//|--MONEY MANAGEMENT CONDITION:           |
//+----------------------------------------+
     {
      if(MONEY_MANAGEMENT_TYPE == A
      && RISK_TYPE == L)
      {
       int ConsecutiveLosses = 0;
       Count(ConsecutiveLosses);
       if(ConsecutiveLosses > 1)
       lots = Lot_Start * 2;
      }
     }

In this way, when the condition is true, it double my lot but i want it to double my lot when a profit is recorded. 

it's not over, i was testing it but i realise that if i put like this (for example):

if(HistoryDealGetDouble(ticket, DEAL_PROFIT) > 0 
&& ConsecutiveALosses > 1)

In this way nothing happened.

Thanks to everyone, by advance. I wish to all a great day.

Kind Regards.

 
By using "break" you're automatically terminating the function once a deal records profit. You should use "continue" instead so the code goes on to calculate the remaining deals.
 
Chidera Anakpe:
By using "break" you're automatically terminating the function once a deal records profit. You should use "continue" instead so the code goes on to calculate the remaining deals.

Hi Friend, Yeah that was this little break;, now it's working great ! problem solved,

Thanks a lot, have a nice day.(y)

 
Mars Arès:

Hi Friend, Yeah that was this little break;, now it's working great ! problem solved,

Thanks a lot, have a nice day.(y)

You're welcome
Reason: