Close at 1pip profit code

 
Please,whats the code that makes a trade close if it has made 1pip profit if any.Thanks
 

Heres a function to close and order if its closing price is above the opening price (as an exercise spot the error!)

void CloseOrder(int ticket)
{
int Slipage=0 ;

if ( OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES) )
   {
    if ( OrderType() == OP_BUY )
      {
       if (Bid > OrderOpenPrice() ) OrderClose(OrderTicket(),OrderLots(),Bid,Slipage,Violet); 
      }
    if ( OrderType() == OP_SELL )
      {
       if (Ask > OrderOpenPrice() ) OrderClose(OrderTicket(),OrderLots(),Ask,Slipage,Violet);  
      }
   }
}
 
I tried inputing it in the attached ea but it doesn't work.I also tried making the OrderClose function invalid if takeprofit had a value >0 and also make OrderClose function valid if takeprofit had a value less than
Files:
 

I said there was an error and asked you to spot it!

    if ( OrderType() == OP_SELL )
      {
       if (Ask > OrderOpenPrice() ) OrderClose(OrderTicket(),OrderLots(),Ask,Slipage,Violet);  
      }

should be

    if ( OrderType() == OP_SELL )
      {
       if (Ask < OrderOpenPrice() ) OrderClose(OrderTicket(),OrderLots(),Ask,Slipage,Violet);  
      }
 
Ickyrus:

I said there was an error and asked you to spot it!

should be

Nice.

It make us thinking about just ask "free" code without at least made some work.

=)