No trade if there was already closed trade
-
Hello everyone.
Stuck with my EA
The idea is 1 trade per day.
Prepared two blocks(area #1 and area#2) to open a trade at specific time under specified conditions.
The idea is to open trade in second block ONLY if FIRST block didn't open any.
First thought was the "No trade" / "if trade" didn't work, but after small investigation looks like issue is:
second block is processed in case where trade from first block is closed before.The question is how to check if there was already some trades closed and to don't allow open second trade for the day.
"no trade/if trade" check running orders, I want to check also closed ones.
Please advice me,thanks

-
-
Hmm not sure how to apply this to my block. If I copy th whole block (area#2) to "On trade" tab then it will only be processed when some trade is already placed.
-
so, to sum it all. Block in area#2 can be processed only if there is no any running trade by block#1 and if there is no any closed trade by block#1 for the day.
-
OK, I see, just a moment, let's see if I can solve this quickly.
-
So, according to your specifications, the first logic should already work. But I think you actually want something different. Now the bot only checks the conditions ONCE AT THE BEGINNING OF THE DAY and if they are not met, it only checks again the next day. I think you only want to make a purchase once a day if the conditions are met, that's different, see Area 4 on this.


-
Have tried like this and looks like doesn't work properly

-
This checked as well.

-
OK, but have you considered that your EA only checks the condition once at the beginning of the day and then not again for the rest of the day? This is a common mistake that is often made in logic. You think that "once a day" means that the condition has to happen once during the whole day, but that's not the case. If the block is above the condition, it will only be checked once at the beginning of the day.
-
@RGoo thank You for your efford and help. I solved the problem, will explain how for future similar strugles, but firstly will reply regarding Your last comment. "If the block is above the condition, it will only be checked once at the beginning of the day." - and this is exactly what I wanted to achieve. One trade per day and if criteria in the first block are met then open a trade , if not ,then checking criteria in second block (what needs to be mentioned "once per day" are diff time). Problem was that "no trade" checking running trades only. In case where first block (once a day) open trade and SL or TP was hit before time set up in second block "once a day", then second block was processed anyway. In final calc. 2 trades were open in such case.
How did I solved it ?
EA checks equity just before trades in first block are open. Second block checks that equity and in case is same then block 2 is processed.

