Close all orders without slippage parameter

 

I want to close all orders on net profit of all orders.  How should I handle the slippage parameter in the ordersclose function?

Can I just close at the market? 

I am rather new at this. 

Thank you... 

 
dukeb:

I want to close all orders on net profit of all orders.  How should I handle the slippage parameter in the ordersclose function?

Can I just close at the market? 

Yes,  if the market is moving slowly enough for the price to be at the current Bid/Ask to execute your trade.  Read up on OrderClosePrice()  you can use it to close a Buy or Sell at the current market price,  bear in mind you first need to OrderSelect() the trade you wish to close.
 
RaptorUK:
Yes,  if the market is moving slowly enough for the price to be at the current Bid/Ask to execute your trade.  Read up on OrderClosePrice()  you can use it to close a Buy or Sell at the current market price,  bear in mind you first need to OrderSelect() the trade you wish to close.

First, I want to thank you for answering both of my posts... that was very kind of you...

By using the OrderClosePrice(), from what I gather by your comment --

1) The trade will definitely close

2) Slippage could be excessive

 

What would your preference be?

Thank you,

 
dukeb:

First, I want to thank you for answering both of my posts... that was very kind of you...

By using the OrderClosePrice(), from what I gather by your comment --

1) The trade will definitely close

2) Slippage could be excessive

As far as I know Slippage will only be excessive if you allow it to be,  OrderClosePrice() should return Bid for an OP_BUY and Ask for an OP_SELL  if price is moving quickly and you allow no slippage you will get a requote and your trade will not close.
 
dukeb: How should I handle the slippage parameter in the ordersclose function? Can I just close at the market? 

Use a large slippage value and you will close at the market (the price the broker has.) But that could be very far away from the price you have (could be a minute old during new releases and/or network problems.)

use a small value and you don't close (requote.)

 
WHRoeder:

Use a large slippage value and you will close at the market (the price the broker has.) But that could be very far away from the price you have (could be a minute old during new releases and/or network problems.)

use a small value and you don't close (requote.)

WHRoeder:

Use a large slippage value and you will close at the market (the price the broker has.) But that could be very far away from the price you have (could be a minute old during new releases and/or network problems.)

use a small value and you don't close (requote.)

 

I am closing trades on a net profit basis. In order to insure a better closing price, should I use a different method?  What is a large slippage number?

Also, I will have multiple orders open.   It seems that one order could close and the next could order fail to close for some reason. How can I ensure that all orders close?

 
dukeb:

 

I am closing trades on a net profit basis. In order to insure a better closing price, should I use a different method?  What is a large slippage number?

Also, I will have multiple orders open.   It seems that one order could close and the next could order fail to close for some reason. How can I ensure that all orders close?

 

Check return value of function, print them, and process them to try to correct the problem (if possible).
 
dukeb: I am closing trades on a net profit basis. In order to insure a better closing price, should I use a different method?  What is a large slippage number?

Also, I will have multiple orders open.   It seems that one order could close and the next could order fail to close for some reason. How can I ensure that all orders close?

double Equity_Target_Saved;

void start(){

if( Net_Profit >= My_Goal ){ Equity_Target_Saved=AccountEquity(); }

if( Equity_Target_Saved != 0 && AccountEquity()>= Equity_Target_Saved ){ CloseAllOrders(); } 

if( MyOrdersTotal() == 0 ){ Equity_Target_Saved=0; }

}

void CloseAllOrders(){

        for(...............){

             if ( OrdreSelect() && OrderMagic() && OrderSymbol() && Blah.Blah.Blh)

             if(AccountEquity() < Equity_Target_Saved){return;} 

             OrderClose(Slippage=0);

}      }

Well thats how I would attempt the No-Slippage solution.

Reason: