I need help with my EA, after the first take profit
-
Hello. I hope somebody can help me again. I really appreciate the help you always get here.
Ok, i am trying to create some sort of grid EA, but not with pending orders (because it can be read).
So right now, just for testing, i have code only three trades. The first one it is placed when we have a moving average crossover, and then it has 60 pips take profit, and with "check profit unrealized" i have -30 pips just to place an order in the opposite direction. If the market goes to the place of the first trade, it will send another one in the same direction. The logic is working the first time (2023.10.01 to 2023.11.01 is the backtesting so you can see what i see. GMT+3 EUR USD), and after ten o'clock, it does the logic properly, but then, after it closes with the take profit, the logic does not work properly. It started sending trades without take profit or respecting the "grid".
Can somebody take a look and tell me what is failing?
Maybe it has the logic in the memory at it has been not reseted?
-
I don't fully understand the logic. What I can see right now is that connecting buy/sell now block below 'for each position' blocks is very risky. Those are loops that can open many trades at once. Specially when connected to another loop below (check profit unrealized). Same with variables. All those variables can be modified more than once per tick because of that.
-
@l-andorrà Thanks for your answer. How would yo do it then?
The explanation. First trade has a take profit of 60, and if it reaches "stop loss" 30 (not a real stop loss, but the place for the next trade), then it sends the second trade. For the second trade is the same logic, take profit 60 (if it reaches it closes all the trades), and 30 for "stop loss" that it is not a real stop loss, but it is the place for the next trade in 30. And it goes on if you place more trades. Always 60 take profit, -30 for the next trade of the grid.
-
I was thinking thay maybe the logic is wrong. Which will be the better way to assign a number or a name to an specific trade, then get the price, and check a specific amount of negative pips to place the next trade?
-
I think you need to decide how to place the second trade, you can use pink blocks Pips Away to place another trade, or place a pending trade?
-
@jstap said in I need help with my EA, after the first take profit:
I think you need to decide how to place the second trade, you can use pink blocks Pips Away to place another trade, or place a pending trade?
I did not know about that block. But how can you assign that block to a specific trade?
-
Add a shared link to see where you want to add, and what particular way would you like to place the trade?
-
@jstap The shared link is in the first post. There i explain a little, and in the third post i explained more detailed. If you need more explanation, please tell me.
But: 1st trade: 60 pips TP, -30 pips= 2nd trade in opposite direction at the first. For the 2nd trade the same: 60 pips TP, -30 for trade in opposite direction, and you can go on with more trades with the same logic.
-
So if I understand it correctly, every time a new trade is open, it needs to be open only if the previous one was 30 pips in loss. Correct? Then, depending on the global profit of all currently open trades, all of them should be closed. Is that what you need?
-
Not exactly, if one trade hit the take profit, all the trades will be close. That logic is alrealy place, that is the part that it seems to be working. in the shared link you can see it placed at the right.
-
the logic behind your EA is simple but your blocks are complicated. lol
-
@keanzoe Yes. And it is wrong, because after the first take profit is hit, the EA stop working properly and send a lot of crazy trades.
Could you please tell me a better way to do it?
-
I did in other way, but the same error. The EA stop working properly after the first take profit is hit.
-
Ok, the problem is in the right module: For each closed position. I am trying to find a solution, but right now i couldn't do it.
-
It seems the logic keeps looking in "For each closed position", so that is the reason that after the first take profit the EA does not work anymore, because the EA looks again there and then it closes all the trades. Anyone knows how to solve this?
-
Why did you put (close trade) block? The trades are closed by tp and sl. Remove that and it should start producing entry again
-
@keanzoe Because i want to close all trades of the grid after a take profit has been hit. That is the problem. The EA keeps looking in "for each closed position", and close all trades. I am going to try with "pips away from open price" to see if that works better.
-
purple trade closed block on the on trade tab will allow blocks to work only once as something happens
-
@jstap said in I need help with my EA, after the first take profit:
trade tab
Ohh! This seems to be the solution. Testing!
And thanks!
-
@acastilla You are welcome