Help please!

Help please! I want to close a position after a certain bar if still in negative profit.
Thanks.
in short: compare iBarShift and OrderOpenTime then if OrderProfit is negative use OrderClose