I have an EA for MT4 which needs some improvements.
Here it is how it works:
When the EA is turned on immediately places three pending orders (short) and three pending orders (long) at a distance = increment from the current price. The orders are also spaced at a distance= increment and TP=SL is at a distance=increment from the farthest from the current market price order.
If the price breaks through the Price level 1 (long or short) the order is filled and additional three orders in the opposite direction are placed at the same price level as the initial three orders, except the new orders are as follows:
Price level 1 – 1 x Lots (lot size specified in the user input)
Price level 2 – 2 x Lots (double the lot size specified in the user input)
Price level 3 – 3 x Lots (triple lot size specified in the user input)
If the price breaks through Price level 2 (Long or short) additional three pending orders are placed in the opposite direction at the same price levels and with the same lot sizes as shown above.
If the price breaks through Price level 3 (Long or short) additional three pending orders are placed in the opposite direction at the same price levels and with the same lot sizes as shown above
If the price reaches the TP=SL price level in either direction all pending order are deleted and the process starts again.
The problem is when the price fluctuates several times between the two price levels of TP=SL but it does not reach them. Then we may have numerous (several hundreds of) pending orders at the same price level and size and rather often the number of open + pending orders will exceed the maximum allowed by the broker ( for IBFX the max is 1,000 total of open and pending orders). IF this number is reached the broker will not allow placing any more pending orders which will result in a loss.
I need to have the EA recoded and consolidate all pending orders by level. It should work as follows:
Every time a price level is reached and a new pending order has to be placed the EA has to check if there is an existing pending order in the same direction at the same price level. If YES that order is deleted and a new pending order is placed at that price level with lot size = the sum of the old and new pending orders. This way the number of pending orders should not be more that two times the number of levels chosen by the user.