is it possible to cose an order on a hourly bar close??

 

HI,

can some one please tell me how to get my EA to close my open position when the hourly bar closes...

I want the open position to close when the hourly bar closes no matter how long it has been open.


i have tried many things ...

eg.


if(Volume[0]==1)

{

OrderClose(......)

return(0);

}


and I tried many other ways but none work...can anyone please help me to get this to work.


Thanks

 
int currentOrderTicket = --whatever the order ticket is--;
int barCount = 0;

if(Bars > barCount){
   if(OrdersTotal() > 0){
      OrderSelect(currentOrderTicket, SELECT_BY_TICKET);

      if(OrderType() == OP_BUY){
         OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue);
      }else if(OrderType() == OP_SELL){
         OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red); 
      } 
   }
  
   barCount = Bars;
}
 
jmca:

Thank you, I will give it a try


cheers

Reason: