Download MetaTrader 5

One order in a time

To add comments, please log in or register
Trade with MetaTarder 5. Download it right now!
zaharulrizal
72
zaharulrizal 2016.02.19 09:05 

hi everyone,

I have problem with my code,

How to make this open sell code only open one order at a time until it close by hit TP or SL then will continue to open another order.

Thanks.

 

extern   double StopLoss = 200;     // StopLoss

extern   double TakeProfit = 100;   //Takeprofit

extern   double LotSize = 0.1;        //LotSize

extern   int Slippage = 3;


int start()

{

   //Opening SELL

   double SL = Bid + (StopLoss*Point);

   double TP = Bid - (TakeProfit*Point);

   double Lot = LotSize;  

   int ticket = OrderSend (Symbol(),OP_SELL,Lot,Bid,Slippage,SL,TP,NULL,0,0);


Vasyl Nosal
18547
Vasyl Nosal 2016.02.19 09:07  

Count opened orders.

if(OrdersTotal()==0)... 

zaharulrizal
72
zaharulrizal 2016.02.19 10:02  
Vasyl Nosal:

Count opened orders.

if(OrdersTotal()==0)... 

Thanks, its work. do you know where i can refer all this things with some example.
Kondalarao Marneni
981
Kondalarao Marneni 2016.02.19 14:53  
zaharulrizal:

hi everyone,

I have problem with my code,

How to make this open sell code only open one order at a time until it close by hit TP or SL then will continue to open another order.

Thanks.

 

extern   double StopLoss = 200;     // StopLoss

extern   double TakeProfit = 100;   //Takeprofit

extern   double LotSize = 0.1;        //LotSize

extern   int Slippage = 3;


int start()

{

   //Opening SELL

   double SL = Bid + (StopLoss*Point);

   double TP = Bid - (TakeProfit*Point);

   double Lot = LotSize;  

   int ticket = OrderSend (Symbol(),OP_SELL,Lot,Bid,Slippage,SL,TP,NULL,0,0);


int ticket;

if(OrdersTotal()==0  && ---aditional conditions if any---)

{

ticket = OrderSend (Symbol(),OP_SELL,Lot,Bid,Slippage,SL,TP,NULL,0,0);

return;

}

Even those if opening more then one trades erase return . Best of luck.  

Vasyl Nosal
18547
Vasyl Nosal 2016.02.19 15:02  
zaharulrizal:
Thanks, its work. do you know where i can refer all this things with some example.
What things?
To add comments, please log in or register