Check if last closed position was stop loss
-
Hi,
I'm trying to check if last closed position was stop loss, and if positive do something. I already tried a lot of pink blocks composition but none of them did work. I've been started with "for each closed position" block and after that "check how it was closed" block, but with no success. I think that I just can't understand how the pink blocks works.
Thanks for your help,
Marc -
What project is this? For "For each closed position" you also need to specify how many positions to loop. By default this is 10, but in your case this needs to be 1.
Many people have problems understanding these blocks, but it's not hard at all. Every "For each... " block checks how many... let's say orders there are, then for each one of them causes the next blocks connected to it to run. A little bit of imagination is needed.
-
Hi fxdreema,
Thanks for your response. The project is Teste1. I put "print message" just to know if it is working. Actually I want to know if last position was stopped and if yes I change the flow of blocks (if it say buy, I sell)
Marc
-
Having nothing here is incorrect in any case. I'm not sure if this means 0 and the block does nothing at all (this will be the better behaviour) or it runs through a;; history positions. Imagine if you have 500 closed positions in the history and checking them all for something on each tick...
In MT5 you can have 1 position per symbol. If a running position is stopped, then you just end up with no running position. You are actually using "No position is running" in this project, so I think I don't understand what you want to do
-
This is the logic:
- If there are no position (block 9 is true) and the last price (close) is above the open price, it opens a position (block 6)
- If position is running (block 9 is false) and the price goes below the open price, it close the position (block 14),
- after that no position is running and it opens another position (block 4)
But if the bar opens up and the market continues goes up on item 2), the position will be stopped and after that will be open an another position at the same direction (block 6). in this case (trade was stopped), what I want is to open a position in another direction (block 4).
If you check the Teste1 again I just changed the project to what I supposed to work. But it didn't work.
PS: I'm sorry if I can't make my self clear, but English is not my native language.
Marc
-
For some reason my post is broken, I don't know why

Anyway. I think you want to do it in this model:
No Buy => Condition to Buy => Close positions => Buy
No Sell => Condition to Sell => Close positions => SellThese are 2 chains of blocks, almost the same, but one of them is for buys and the other is for sells.
Now from what I see you open a new position and on the very next moment it will be closed because of the opposite condition. I didn't checked it, but I'm pretty sure that this is the case.
-
Yes, is almost it:
No position => condition to buy => buy => condition to close buy => close buy
No position => condition to sell => sell => condition to close sell => close sellBut if the last closed position was "stop loss", then:
No position => condition to buy => sell => condition to close buy => close sell
No position => condition to sell => buy => condition to close sell => close buyand yes, it open a new position and probably close a few minutes later.
-
No, no... it's not "No position" with all default settings, it's "No position" that is set to work only with Buys, and another blocks like this set to work for Sells.
-
-
Actually, is like the attached file.
......
EA_OpenUpSell.PNG -
Now this is what happens and is wrong or this is how it should be?
Note that I am not sure what you really want and I'm guessing, that's why I'm proposing what I think you want to achieve
