The author of the ideaΒ –Β
mq5 code authorΒ –Β
The EA analyzes candles #1 and #2.
Example of opening and closing for SELL
Open conditions – there is no a single position on the market
Β Β Β Β Β Β //--- buy Β Β Β Β Β Β if((rates[1].open>rates[2].open) && (rates[1].close<rates[2].close)) Β Β Β Β Β Β Β Β { Β Β Β Β Β Β Β Β double lot=TradeSizeOptimized(); Β Β Β Β Β Β Β Β OpenBuy(lot,0.0,0.0); Β Β Β Β Β Β Β Β return; Β Β Β Β Β Β Β Β } Β Β Β Β Β Β //--- sell Β Β Β Β Β Β if((rates[1].open<rates[2].open) && (rates[1].close>rates[2].close)) Β Β Β Β Β Β Β Β { Β Β Β Β Β Β Β Β double lot=TradeSizeOptimized(); Β Β Β Β Β Β Β Β OpenSell(lot,0.0,0.0); Β Β Β Β Β Β Β Β return; Β Β Β Β Β Β Β Β }
If there is an open position, check the close condition
Β Β Β Β Β Β if(rates[1].open<rates[2].open && (rates[1].close<rates[2].close)) Β Β Β Β Β Β Β Β { Β Β Β Β Β Β Β Β ClosePositions(POSITION_TYPE_BUY); Β Β Β Β Β Β Β Β return; Β Β Β Β Β Β Β Β } Β Β Β Β Β Β if(rates[1].open>rates[2].open && (rates[1].close>rates[2].close)) Β Β Β Β Β Β Β Β { Β Β Β Β Β Β Β Β ClosePositions(POSITION_TYPE_SELL); Β Β Β Β Β Β Β Β return; Β Β Β Β Β Β Β Β }