Hi Everyone I've been stuck on something for over a week. No matter what I try, I cannot get this to work. I want my EA to simply add the profit and loss of two open trades together, and if the combined profit and loss exceeds a certain profit margin, it must close both trades. But it always closes both trades in a loss. It is as if it closes the first trade in a loss as soon as the other trade goes in profit, but then fails to close the profitable trade until it goes into a loss. It always prints dLoss=0. So it is obviously not calculating the losses properly. Is this because OrderProfit() does not take losses into account? What is the opposite function for OrderProfit()? The best code I have so far is this one. Will someone please look and see if you notice any problems. Thank you very much.
Hi Everyone I've been stuck on something for over a week. No matter what I try, I cannot get this to work. I want my EA to simply add the profit and loss of two open trades together, and if the combined profit and loss exceeds a certain profit margin, it must close both trades. But it always closes both trades in a loss. It is as if it closes the first trade in a loss as soon as the other trade goes in profit, but then fails to close the profitable trade until it goes into a loss. It always prints dLoss=0. So it is obviously not calculating the losses properly. Is this because OrderProfit() does not take losses into account? What is the opposite function for OrderProfit()? The best code I have so far is this one. Will someone please look and see if you notice any problems. Thank you very much.