Disliked{quote} I don't understand how it's possible that the Target Based is reached before the Middle Point. For instance, if a buy limit is hit and then the price goes up, I seem quite obvious that the price will reach the middle point well before the price target (unless the price target is very small). Could you clarify? Thank you!Ignored
Imagine this case,
Middle Point will be reached first if:
- Price movement causing first order to be executed / opened, then the price retracts back and executing second order on the other side. Once all orders are profit, middle point logic will close it.
- Price movement causing first order and second order on the same side to be executed / opened. Once all orders are profit, middle point logic will close it.
Then, Target Based will be reached first if:
- Price movement starts trending and executes (for example) 5 orders, then the price retracts back. Although all orders not in profit, if total profit is exceeding the target based, then all orders will be closed.
Now, why the Middle Point logic doesn't close when the first order is executed?
Because in GTLIMITEURUSD2 set, it has Middle Point trigger. If you set "Middle Point Activation" to 2, here's the logic.
Inserted Code
(((BuyCount + SellCount) >= CloseMiddlePointAftOrders && CloseMiddlePointAftOrders > 0) || CloseMiddlePointAftOrders <= 0) && AllPositiveProfit && Ask <= AskTH && Bid >= BidTH))
It will check whether the total count of opened orders from both sides is more than 2, AND it will check whether all is in profit. The rest is the bug (useless logic).
Now, get back to your case. If a buy limit is hit first, then the price goes up, that means only 1 order executed. In this case, the logic above is not hit yet.
Then the price keep going up, the first sell limit is hit first, but then the price is moving up. In this case, the logic above is only fulfilled one side, this logic:
Inserted Code
(BuyCount + SellCount) >= CloseMiddlePointAftOrders && CloseMiddlePointAftOrders > 0) || CloseMiddlePointAftOrders <= 0
Now, then imagine that the price is moving down a little bit causing both orders to be in positive, then the whole chunk of logic will be TRUE and orders will be closed.
Another case, imagine the price is not moving down, it keeps moving up until the 5th order executed, then it retracts back. If let's say price goes down until reaching again the 2nd order, in this case normally Target Based will reach first.
All of this scenario, you can simulate it on the excel file I've given: http://rdzgridtraps.codeplex.com/releases
Just try to simulate it there.
If you ask me to code/fix your EA... it's probably not for free...