The Ea must open orders on the new signal

The problem is, my EA when attached to a chart will execute a [buy/sell order] almost immediately, because its buy/sell condition has been met. However, this could be halway through or at the end of the trend. The EA doesn’t discriminate. What I need is an algorithm/code that stops the EA from doing that and instead wait for the signal to occur for the first (second?) time. Is there any such code or solution to this problem?

Hi,
The answer is no. You create the strategy . The code is just executed what you has written. So you should reconsider your entries by adding more rules or to change the existing one.