Stop Loss Hiding

 

Hi coding expert friends,

Please help to code an indi that 'hide stop loss'. So the broker does not know that we have set a stop loss.

Thanks,

anton

 
anton1:
Hi coding expert friends,

Please help to code an indi that 'hide stop loss'. So the broker does not know that we have set a stop loss.

Thanks,

anton

anton

Indicators can not handle stop losses. Only EAs and scripts can.

 

Hi Mladen,

Yes, you are right. I mean an EA.

Would you please help me.

Thanks and Regards,

Anton

 

No body want to help me?

 

At the beginning

extern int StopLoss=0;//|------------------------stop loss

extern int TakeProfit=0;//|----------------------take profit

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

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

extern int Magic=2009;//|------------------------magic number
 

At the middle after int start add this

double LastBuyOpenPrice=0;

double LastSellOpenPrice=0;

int BuyOpenPosition=0;

int SellOpenPosition=0;

int TotalOpenPosition=0;

int cnt=0;

for(cnt=0;cnt<OrdersTotal();cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic&&OrderCloseTime()==0)

{

TotalOpenPosition++;

if(OrderType()==OP_BUY)

{

BuyOpenPosition++;

LastBuyOpenPrice=OrderOpenPrice();

}

if(OrderType()==OP_SELL)

{

SellOpenPosition++;

LastSellOpenPrice=OrderOpenPrice();

}

}

}

if((HideSL&&StopLoss>0&&Bid0&&Bid>(LastBuyOpenPrice+TakeProfit*Point)))

{

CloseBuyOrders(Magic);

}

if((HideSL&&StopLoss>0&&Ask>(LastSellOpenPrice+StopLoss*Point))||(HideTP&&TakeProfit>0&&Ask<(LastSellOpenPrice-TakeProfit*Point)))

{

CloseSellOrders(Magic);

}
 

then close out at the end with this...

//|---------close buy orders

int CloseBuyOrders(int Magic)

{

int result,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)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3);

switch(OrderType())

{

case OP_BUYLIMIT:

case OP_BUYSTOP:

result=OrderDelete(OrderTicket());

}

}

}

}

return(0);

}

//|---------close sell orders

int CloseSellOrders(int Magic)

{

int result,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)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3);

switch(OrderType())

{

case OP_SELLLIMIT:

case OP_SELLSTOP:

result=OrderDelete(OrderTicket());

}

}

}

}

return(0);

}
 

mwambafx,

thanks for your kind sharing.

but, I am no good at coding at all.

would you please make it for me?

thanks and regards,

anton

 
anton1:
mwambafx,

thanks for your kind sharing.

but, I am no good at coding at all.

would you please make it for me?

thanks and regards,

anton

sure no problem. let me know how to help. have a blessed week.

 

Would you please to code the EA fully?

Thanks,

mwambaFX:
sure no problem. let me know how to help. have a blessed week.
 
mwambaFX:
then close out at the end with this...
//|---------close buy orders

int CloseBuyOrders(int Magic)

{

int result,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)

{

OrderClose(OrderTicket(),OrderLots(),Bid,3);

switch(OrderType())

{

case OP_BUYLIMIT:

case OP_BUYSTOP:

result=OrderDelete(OrderTicket());

}

}

}

}

return(0);

}

//|---------close sell orders

int CloseSellOrders(int Magic)

{

int result,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)

{

OrderClose(OrderTicket(),OrderLots(),Ask,3);

switch(OrderType())

{

case OP_SELLLIMIT:

case OP_SELLSTOP:

result=OrderDelete(OrderTicket());

}

}

}

}

return(0);

}

Wouldn't it ignore the pending orders?

Reason: