The routine gets somewhat involved. You need to calculate the pip profit attained since the order was started. Subtract your trail factor. If trail would be activated check if order is actually profit. If that's the case let order to be closed. You are going to need to use iBarShift or even iLowest to calculate the highest or lowest price attained since order production. Start with the OrderOpenTime() and proceed forward to current time and loe the Highest/Lowest price (based on if its a BUY or SELL). Also keep tally of OrderProfit() - If its in the profit near the order with OrderClose().




Reply With Quote