How to exit at bar end? (Code)

 
Can anyone advise me on a line of code to put into an EA to exit an open order on the termination of the current bar?

Everything I try closes the order as soon as it opens as the 'Close' corresponds to the current price.

Most frustrating.

Thanks for any suggestions.

Egwig.
 
if (Volume[0]<1) exit an open order
 

if (Volume[0]<1) exit an open order

It was shown in another thread that volume can jump (previous 5, new 7-8) occasionally, so the above may be unreliable.

static datetime Time.newBar; bool newBar = (Time[0] > Time.newBar);
if (newBar) {		     Time.newBar = Time[0];
  //...
}
 
WHRoeder:

It was shown in another thread that volume can jump (previous 5, new 7-8) occasionally, so the above may be unreliable.


Thank you, guys.


Your ideas are welcome and appreciated.


My next problem is finding a way to stop an order from re opening after breaching the TakeProfit.


How to restrict to one trade per bar.


Any suggestions would be welcome.


Thanks again.


Egwig

Reason: