Aurix Exchange

close all for buy ,close all for sell script

hello everybody,

someone can write script for closeall buy opened positions?and closeall sell opened positions ?

i want to separate scripts for this

thanks
 

micscal

Member
hi, you can you this script.
close buy:
void CloseBuy() {
int TotalOpen = OrdersTotal();
for(int ct=TotalOpen-1;ct>=0;ct--)
{
OrderSelect(ct, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), Bid, 5, Red );
}
}
}

close sell:
void CloseSell() {
int TotalOpen = OrdersTotal();
for(int ct=TotalOpen-1;ct>=0;ct--)
{
OrderSelect(ct, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), Ask, 5, Red );
}
}
}
 

krish

Member
hi, you can you this script.
close buy:
void CloseBuy() {
int TotalOpen = OrdersTotal();
for(int ct=TotalOpen-1;ct>=0;ct--)
{
OrderSelect(ct, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), Bid, 5, Red );
}
}
}

close sell:
void CloseSell() {
int TotalOpen = OrdersTotal();
for(int ct=TotalOpen-1;ct>=0;ct--)
{
OrderSelect(ct, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), Ask, 5, Red );
}
}
}

can u share it as mq4 file
thanks
 

civicsi411

New member
close all

close all

Here's a close all script and a few others.

PHP:
http://codebase.mql4.com/scripts
 

Attachments

  • closeall1.ex4
    2.1 KB · Views: 0
  • CloseAllAtEquityLevel.mq4
    4.9 KB · Views: 0
  • CloseTrades_After_Account_Loss_TooMuch.mq4
    3.2 KB · Views: 0
  • CloseTrades_After_Account_Profit_Reached.mq4
    2.5 KB · Views: 0

Aurix Exchange
Top