MT5 projects only: "For each closed position" not working properly when "Buy/sell pending order" blocks are used
-
Hi @fxDreema
It seems like the "For each *** position" blocks (and other blocks related to trade history) are not working properly when I use "Buy/sell pending order". It seems to start passing only after a number of positions (opened from pending orders) have been closed, and it doesn't respect the rules under "loop settings", because the information I need (profit) only updates after several positions have been closed, even though I choose only 1 in "Not more than "n" history trades". It works perfectly when "buy/sell now" blocks are used.
Can you please check that?
See images below
The project: http://fxdreema.com/shared/Hlsgw9H9c

Closed positions, but no comments shown

Comments appear after many positions are closed

-
This is where it appears to me:

What if you move the chart left-right with the mouse a little bit? Sometimes objects are printed with delay in MT5.
-
I tried and it still doesn't work. I used the comment block to illustrate the problem I'm having.. but in fact it seems to be a problem with the history of trades created from pending orders.... for example, the martingale function doesn't work on the "buy/sell pending order" blocks. For example: fxdreema.com/shared/D4HmSiFE
The martingale doesn't add lots after loss... or whenever I try to search history trades with "for each position" or "bucket of position", it never gives the right results when the history is made of trades created from pending orders. I tried in 4 different computers and the problem is the same.. can you please check if , the martingale on pending orders work for you? fxdreema.com/shared/D4HmSiFE . (it's onTick)
-
I think that the problems happen when the orders have expiration, I will make some tests to see what is wrong.
-
I don't know what happens, but I was able to see the problem (always 0.1 lots in Martingale) once and then magically everything works fine. Very strange, I think this happened with your "Comment" example, and also few months before when another guy reported something like this. I wonder what someone else can see - is there a problem?
-
Ok, here is mine easy to test example - https://fxdreema.com/shared/mRvSlNKW Now I got the problem every time and also quickly.
- Initially I create 1 pending order and 1 trade. The order has expiration of 12 minutes and expires before the trade is closed by SL.
- After that in "on Tick" a new order is created and the EA is self terminated.
That second order is expected to have lot size of 0.2 lots, but it opens 0.1 lots. If I remove block 2 (the first pending order that expires) everything is fine with the second order, it opens 0.2 lots. So it looks that something is wrong with that first order, maybe because of the expiration.
I'm sleepy now and I think I am going to sleep, but I will try to fix this problem tomorrow.
-
Great if you can look it up...
Maybe this can help you further: I also thought the expiration was the problem, but at least here it's not. I tried without expiration and problem continues... I also made another type of expiration (blocks: "for each pending order -> check age (open time, pass if older than X min) -> delete pending orders"), and the problem continues as wells.
-
I think I fixed these problems.
For Martingale in the "pending order" blocks, I'm confused how it should work. Normally this strategy requires one position at a time. But these are pending orders - they don't even exist. If you place a new pending order with Martingale, what should be its lot size, from where it should be calculated - from some previous position or from the previous pending order? And I think that every answer to this question is correct and incorrect, because Martingale is not supposed to work like that

-
I agree that there is no golden rule on how martingale should work. In my opinion the EA should look at the lot size and overall outcome (profit/loss) of the previous position, independently of how it was open (market or pending order) to decide on the next pending order's lot size, but this is just my opinion.
Either way, now that the function is working (I've tested a "simple martingale" from pending orders at least) the user can see how the block behaves and decide for himself what to do...
As always, fxDreema empowering trader's creativity... best tool on the whole internet
