Martingale system with increment of lot size 0.01 to 0.03 when 1st loss occur lot will be 0.02, 2nd loss occur lot will be 0.03 and upto 0.03.

 

Hello Respected community Coder...

I wan't to use "Martingale system with increment of lot size 0.01 to 0.03. PLEASE WHAT IS CODE ? 

I post MACD EA WORKING CODE, Guidance will be appreciated.

 // External variables
extern double LotSize = 0.01;
extern double StopLoss = 0;
extern double TakeProfit = 0;
extern double TrailingStopLimit = 0;
extern double TrailingStopStop = 0;
extern int MagicNumber = 23310;


// Global variables
int LongTicket;
int ShortTicket;
double RealPoint;



// Init function
int init()
{
      RealPoint = RealPipPoint(Symbol());
     
}


// Start function
int start()
{
        //Variables
        

                
                
// Long
OrderSelect(LongTicket,SELECT_BY_TICKET);
if(OrderCloseTime() != 0 || LongTicket == 0)
{
                
                    
bool buy_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)  > iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0)  ;
bool buy_condition_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)> Ask +0.0007 ;

                                 
if( buy_condition_1   )
{

LongTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);
OrderSelect(LongTicket,SELECT_BY_TICKET); 
double OpenPrice = OrderOpenPrice();
            
             
            if(StopLoss > 0) double LongStopLoss = OpenPrice - (StopLoss * RealPoint);
            if(TakeProfit > 0) double LongTakeProfit = OpenPrice + (TakeProfit * RealPoint);
            
            
if(LongStopLoss > 0 || LongTakeProfit > 0) 
{
               bool LongMod = OrderModify(LongTicket,OpenPrice,LongStopLoss, LongTakeProfit,0);
}
}
}
                

//Close long
      if (OrdersTotal() > 0)
{              
                
                    
                
                    
                    
bool close_buy_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)  < iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0)  ;

                    
if( close_buy_condition_1   )
{
OrderSelect(LongTicket,SELECT_BY_TICKET);
if(OrderCloseTime() == 0 && LongTicket > 0)
{

double Closed = OrderClose(LongTicket,OrderLots(),Bid,0,Red);
}
    }
}
                

               
// Short
OrderSelect(ShortTicket,SELECT_BY_TICKET);
if(OrderCloseTime() != 0 || ShortTicket == 0)
{
 
                
                                    
bool sell_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)  < iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0)  ;
bool sell_condition_2 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)  > Bid +0.0007;    
                                    
if( sell_condition_1   )
{
   
ShortTicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,"Sell Order",MagicNumber,0,Red);
OrderSelect(ShortTicket,SELECT_BY_TICKET); 
OpenPrice = OrderOpenPrice();
            
            
            if(StopLoss > 0) double ShortStopLoss = OpenPrice + (StopLoss * RealPoint);
            if(TakeProfit > 0) double ShortTakeProfit = OpenPrice - (TakeProfit * RealPoint);
            
if(ShortStopLoss > 0 || ShortTakeProfit > 0) 
{
               bool ShortMod = OrderModify(ShortTicket,OpenPrice,ShortStopLoss, ShortTakeProfit,0);
}
}
}
                

                
             

                
//Close Short
if (OrdersTotal() > 0)
{
 
                 
                                     
bool close_sell_condition_1 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0)  > iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0)  ;

 
if( close_sell_condition_1   )
{
OrderSelect(ShortTicket,SELECT_BY_TICKET);
if(OrderCloseTime() == 0 && ShortTicket > 0)
{

Closed = OrderClose(ShortTicket,OrderLots(),Ask,0,Red);
}
                        }
}
 

              
               

return(0);
}


// Pip Point Function
double RealPipPoint(string Currency)
{
int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
return(CalcPoint);
}
       
 
What you want isn't clear please specify more details like what condition happens to increase the lot?
 
Mad Gamer:
What you want isn't clear please specify more details like what condition happens to increase the lot?
When 1st loss occur lot will be 0.02, 2nd loss occur lot will be 0.03  & upto 0.03......thanks for response. 
 
vilas korke:
do not reply inside the quote please.
 

in the section // long

underneath it is OrderSelect

then underneath that you must add code: 

if (OrderProfit() <0){ LotSize=LotSize+0.01;} if (LotSize >= 0.03){ LotSize=0.03;}

if (OrderProfit() >=0){ LotSize=0.01;}


Also do the same by //short

Reason: