Help : Open trades by sell/buy active

 

Dear all,

im using mt4 and i would like to know how to open trade (sellstop or buy stop) if only buy or sell active ?

if( OrdersTotal() only have 1 (one) open buy or open sell)

{

OpenTrades();

}

if 1 open buy active, will open sell stop or

if 1 open sell active, will open buy stop

Thanks in advance for any help.

Ancorp

 
ancorp:
Dear all,

im using mt4 and i would like to know how to open trade (sellstop or buy stop) if only buy or sell active ?

if( OrdersTotal() only have 1 (one) open buy or open sell)

{

OpenTrades();

}

if 1 open buy active, will open sell stop or

if 1 open sell active, will open buy stop

Thanks in advance for any help.

Ancorp

You can do something similar to this :

int start()

{

if (OrdersTotal()==1 && isOpened(OP_SELLSTOP)) // code to open buy stop

if (OrdersTotal()==1 && isOpened(OP_BUYSTOP)) // code to open sell stop

return(0);

}

bool isOpened(int type)

{

for (int i=OrdersTotal()-1; i>= 0; i--)

{

if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

if (OrderType()==type)

return(true);

}

return(false);

}