Spécifications
write me an MQL code that will work on mt4 and mt5 and follow these specific instructions...
This code is for forex trading EA and will work in any time frame, using the candle sticks formed on that time frame to make its trading decisions. it should work with all forex pairs, indices and commodities. The instructions are as follows:
Entry Condition: when there are two or more consecutive bearish close (price opens higher and closes lower) candle, then followed by a bullish close (price opens lower and closes higher) candle stick on the time frame to be traded, set a stop order(sell-stop) at the opening price of the first bullish candle. this should be set only at the close of the bullish candle. Also, when there are two or more consecutive bullish close candles, and followed by a bearish close candle, set a buy stop order at the opening price of the first bearish close candle. This should also be set at the close of the bearish candle.
Risk Management conditions: for the sell stop order, set stop loss at the opening price of the most recent previous bearish candle opening price that is higher than the highest price of the candle which the opening price was used to set the pending/stop order. for the buy stop order, set stop loss at the opening price of the most recent bullish candle which is lower than the lowest price of the candle which its opening price was used to set the pending /stop order...
Number of Trades to be Opened: Always set two pending orders at a time (as soon as the conditions for setting the orders are met). for one of the trades, set a R;R of 1:2, and set the R:R for the second trade to 1:5.
Trade will be managed as follows: If the stop order is triggered, and the price hits the 1:2 target, the remaining open trade should move its stop loss to BE, and secure 0.5%R. This strategy does not require any indicators.
NB
All parameters should be adjustable.
Lot size: lot size should be calculated from the account balance, so that the risk on each of the trades should be 0.25%. the default lot size for entry to be 0.01 lots.
the EA is not allowed to open any other trade until the first 2 trades opened have been closed in profit or loss.
All trades ( Opened pending orders) opened, but not executed should be closed after 1 hour, and then the search for a new trade setup should begin.