Modifying wxisting trades
-
Hi, I'm new here so will get straight on topic.
I was looking into the blocks settings, but couldn't find what I need. Combinind several blocks didn't help either.
I need this: If nore than "n" trades are running, change all TP ans SL to the last trade's TP and SL.
and this: How to find the type of the last trade ?Thanks.
-
Last trade seems to be important, many people are interested in it

http://fxdreema.com/shared/S3cqf4tE
In this example:- Some trades are created, 1, 2, 3, 4... and when 5'th trade is created... (we go to the yellow output of block 2)
- 5'th trade is loaded using block 4 and in blocks 5 and 6 SL and TP level of 5'th trade are saved for later use. "Formula" block is used, which creates a global variable (Result) in fxDreema and saves value in it. "lastSL" and "lastTP" results are created.
- Now one by one, all trades are selected using block 7. They are modified using block 8 - every stop-loss becomes "lastSL", take-profit becomes "lastTP".
In this example in blocks 4 and 7, only Buy type of trades are allowed. Well, depending on where is the last trade's SL and TP and open prices of older trades, there can be problems to modify SL and TP is SL is above open price or TP is below open price.
How to find the type of the last trade:
Start trades loop (set "1" for the last parameter inside) -> (in loop) Check trade/order type -
Same thing, another approach:
http://fxdreema.com/shared/ZQJOcQgJcHere "Trade" event is used, and when 5'th trade is created, block 6 passes and block 7 executes as many times as many other trades are existing. No "Formula" blocks here, because in block 8 parameters of the trade that caused the event are used.
-
Thank you for your reply.
Unfortunately because of my spelling mistake some confusion has been created.
If more than "n" trades are running, for example there is 1 trade running and 1 pendin. The price reaches the pending order and opens the trade, when it happened, the TP/SL from the 1st trade must be changed to the TP/SL of the 2nd trade (last) and so on.
So basically with each new opened trade, the TP (and/or SL) from all previous running trades must be changed to the TP (and/or SL) of the last opened trade.
The idea is that all trades must have same TP/SL at a time and when the TP/SL is hit, all the trades will close.Thanks for help again.
-
When pending order opens, it becomes trade and total number of trades is incremented with +1.
-
Hello FxDreema,
Thanks for your explanation, it was really helpful. The field with "Trades" is really great. I have one question though.
If there will be 2 separate logical trees in the "Trades" field. One is "(event) new trade opened" and the second "(event) trade closed"
What if these 2 logical trees will NOT be connected but stay there separately, will they work accordingly, one when a trade is opened, and the other when the trade has closed ? -
Yes, they should be used that way. In any event workfield (I mean, Init, Tick, Trade, Timer, Deinit), when there are more than one independent logical trees, they are all executed, one after another.
See this example here: http://fxdreema.com/demo/using-trade-event-tick