I am coding a EA which uses 2 MA. I have some difficult when Open and Close order. When MA1>MA2 the EA will Open a Buy order and then it Close order when the profit is 20pips. However, when the EA Close the order, the MA1 is still cross up the MA2 so the EA open a new order again. It is not a good way I expect. So I want the EA Open an oder at the first candle once the MA1 > MA2 ( Buy) or the MA1<the MA2( Sell)
Please anybody help me to solve this situation ?