Download MetaTrader 5

please,what is wrong in my code??????,its for lot size calculation

To add comments, please log in or register
itriad
162
itriad  

hello,thank you for any help

sometime the calculation function go wrong,whats happens???? last bug is this one, my accountequity is "<10000.00&&>9900.00" my ea must open position of 0.2 lot,but it open position of 0.1 lot ???????

here is the code

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
 int start()
  
  
   
         {                 //lotsize calculation
           
             double Lot         = 0.00;
             double capital     = AccountEquity();
             
           
             if ( capital>=                  10000.00) {Lot=0.1;}
             if ( capital<10000.00&&capital>= 9900.00) {Lot=0.2;}
             if ( capital< 9900.00&&capital>= 9800.00) {Lot=0.3;}
             if ( capital< 9800.00&&capital>= 9700.00) {Lot=0.4;}
             if ( capital< 9700.00&&capital>= 9600.00) {Lot=0.5;}  
                      
          
Keith Watford
Moderator
9644
Keith Watford  
Print your account equity so that you can check equity at the time of placing the trade Show your code for OrderSend Is there any other code that could change the value of Lot?
whroeder1
14785
whroeder1  
You also could simplify the code
double Lot         = 0.00;
double capital     = AccountEquity();
if ( capital>=                  10000.00) {Lot=0.1;}
if ( capital<10000.00&&capital>= 9900.00) {Lot=0.2;}
if ( capital< 9900.00&&capital>= 9800.00) {Lot=0.3;}
if ( capital< 9800.00&&capital>= 9700.00) {Lot=0.4;}
if ( capital< 9700.00&&capital>= 9600.00) {Lot=0.5;}
double capital     = AccountEquity();
if (      capital <  9600.00) {double Lot=0.0;}
else if ( capital <  9700.00) {Lot=0.5;}
else if ( capital <  9800.00) {Lot=0.4;}
else if ( capital <  9900.00) {Lot=0.3;}
else if ( capital < 10000.00) {Lot=0.2;}
else                          {Lot=0.1;}
itriad
162
itriad  
yes is better like this,thank you
To add comments, please log in or register