Hello! Need some help please

 
what happens in my code,its simple code for modify lot size,i give you 1 example if account balance is <10000 lot size = 0.1,then if account balance < 9900 lot size=0.2 etc etc...... thank you
//------------------------------------------------------------------------------
// switch.mq4

//------------------------------------------------------------------------------
double Lot  = 0.1;

int lotsize;
//------------------------------------------------------------------------------
int start()                             // Special function start()
  {
   
   double capital     = AccountBalance(); 
                             
   
             if(capital<10000.00) 
             { 
             lotsize = 1; 
             }
             if(capital<10900.00) 
             { 
             lotsize = 2; 
             }
             if(capital<10800.00) 
             { 
             lotsize = 3; 
             }
             if(capital< 10500.00) 
             {
             lotsize = 4; 
             }
             if(capital< 10300.00) 
             { 
             lotsize = 5; 
             }
             if(capital< 9700.00) 
             { 
             lotsize = 6; 
             }
   
//------------------------------------------------------------------------------
   switch (lotsize)                          
     {                                  
      case 1 : Lot=Lot;           
      case 2 : Lot=Lot*2; 
      case 3 : Lot=Lot*3;     
      case 4 : Lot=Lot*4;         
      case 5 : Lot=Lot*5;          
      case 6 : Lot=Lot*6;           
      }
      
//--------------------------------------------------------------------------------------------------------------------------------------------------------            
           
   
                         
//--------------------------------------------------------------------------------------------------------------------------------------------------------                          
//----
   return(0);
  }
//+------------------------------------------------------------------+
      
 
the code does not trade the programmed lotsize???thank you
 
the entry signal is not there,my problem is only to modify lotsize in accord with account balance thank you
 
   switch (lotsize)                          
     {                                  
      case 1 : Lot=Lot;   break;           
      case 2 : Lot=Lot*2; break; 
      case 3 : Lot=Lot*3; break;     
      case 4 : Lot=Lot*4; break;         
      case 5 : Lot=Lot*5; break;          
      case 6 : Lot=Lot*6; break;
      default: Lot=Lot;   break;           
     }

It needs to break out of the switch when it finds a match also you can use default in case none of them match.

 

Here are my beliefs, bare with me a bit... I would create a function that could be flexible enough for the trade to leave the EA unattended. Use a percentage of the balance for the trade of use other equation for that automated purpose. Call this function whenever you need it and it will return a lot size to be used.

A piece of code:

Lots=RiskCapital/100*AccountBalance()/(TakeProfit*pipMultiplier*MarketInfo(Symbol(),MODE_TICKVALUE)*pipMultiplier);

That is the calculation using Percentage...

 
riskoff: what happens in my code,its simple code for modify lot size,i give you...
double Lot  = 0.1;
:
      case 2 : Lot=Lot*2; break; 
  1. The first time you change Lot to 0.2 and open
  2. The second (assuming balance hasn't changed the case) you change Lot to 0.4
  3. The third time you change Lot to 0.8 ...
Don't modify your externals.