Aurix Exchange

Hide TP + SL Code

In the extern parameters :

Code:

extern bool HideSL=false;//|---------------------hide stop loss
extern bool HideTP=false;//|---------------------hide take profit

In the start body :

Code:

//|---------hidden sl-tp

if(HideSL&&StopLoss>0)
{
CloseBuyOrdersHiddenSL(Magic);CloseSellOrdersHiddenSL(Magic);
}
if(HideTP&&TakeProfit>0)
{
CloseBuyOrdersHiddenTP(Magic);CloseSellOrdersHiddenTP(Magic);
}

In the functions :

Code:

int CloseBuyOrdersHiddenTP(int Magic)
{
int total=OrdersTotal();

for (int cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY&&Bid>(OrderOpenPrice()+TakeProfit*dPoint))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
}
}
return(0);
}

Code:

int CloseBuyOrdersHiddenSL(int Magic)
{
int total=OrdersTotal();

for (int cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY&&Bid<(OrderOpenPrice()-StopLoss*dPoint))
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
}
}
return(0);
}

Code:

int CloseSellOrdersHiddenTP(int Magic)
{
int total=OrdersTotal();

for(int cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL&&Ask<(OrderOpenPrice()-TakeProfit*dPoint))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}

Code:

int CloseSellOrdersHiddenSL(int Magic)
{
int total=OrdersTotal();

for(int cnt=total-1;cnt>=0;cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==Magic&&OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL&&Ask>(OrderOpenPrice()+StopLoss*dPoint))
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}
 

Aurix Exchange
Top