Help with multiple/basket orders for MT4
-
Hi,
Can anyone help me with a function to do a second basket order (if the signal hits again) after the currently open basket order moved stop loss to break even, if it is possible using fxDreema/MT4?
So i want the open risk to be max one basket order. The basket order for me is 3 different orders with different take profits but same SL.
Sequence example:
- Send three orders when signal hit first time.
- Take profit for first order is hit. Two orders from the first basket sill open.
- Trailing stop is moved to break even (or further using trail) on current basket order (2 open orders).
- Signal hits again with the two orders from the first basket order is still open.
- Second basket order of 3 orders are sent. This is the same orders as sent as basket 1 (exactly the same SL and TP) but it is only sent if the risk is zero on the first basket of orders, in this example the 2 open orders are at break even.
So this last step is what i am struggling with.
I have read the book by Andrew R. Young on Expert Advisor programming but i am not a programmer and don't understand the section on multiple orders and how i can modify it to fit my wish...
Thanks very much for any help!
-
@dalkungen So if I understand it correctly, the EA is supposed to:
- Open three simultaneous trades every time market conditions are met. All of them have the same SL distance in pips but only the first one has a TP in pips.
- When TP of the first one is hit, the 2 remaining trades move their SL to BE.
- If market conditions are met again, 3 new trades are open with the exact same distance in pips for SL and TP as the first time.
Is that correct?
-
@l-andorrà First, sorry for opening multiple treads. My first time using this forum. My mistake.
No not exactly, i basically want to open the 3 new trades only if the SL has been moved atleast to BE on all previous trades. So looking for the condition that checks if previous bucket (3 trades) are risk free. The TP can have been hit or not in those first 3 trades. The important is that its risk fee but number of trades open can be many.
I was watching your youtube clips as well. They are good!
Thanks
-
@dalkungen So is point 1 correct? I think this is exactly what you are suggesting. If all trades have the same distance in pips what conditions are required for the SL to be moved to BE AFTER the first one hits TP?
-
@l-andorrà The first point is correct in the way that it opens 3 trades simultaneously every time market conditions are met but only when risk of previous 3 trades has been moved to BE (zero risk). Basically, first time market conditions are met, i open 3 trades simultaneously with same SL in pips for all 3 (30 pips). All 3 trades has different TP, all in pips (preferable the trade with highest TP in pips will have a trailing stop in addition to the TP in pips). The SL is moved to BE for all 3 trades when price moved 25 pips in profit. At this point when SL is at BE, a second batch of 3 trades will open if market conditions are met. And so it continues, if SL for this second batch is moved to BE then another batch can open if conditions are met.
So i open simultaneously 3 trades which together have my maximum exposure (30pips for each one of the 3 trades in the batch).
Sorry if i explain poorly.
-
@dalkungen Ok. Now I understand it better. And is there any maximum number of open trades simultaeously or not? I tell you this because having many of them can be a problem depending on lot size.
-
@l-andorrà ok great. I use 3 in a bucket but has not set a max for total number of trades open. But would be happy to stop adding trades after lets say 3 buckets so 9 trades total but could happily add more if possible as the risk should never be higher than for 3 trades anyway.
As long as the trend goes in my way i would be happy to add. However, if the trend continues TPs will start hit and the total number of trades will reduce from that as well. The first TP for the first of the trades in a bucket i use only 25bps so that comes off quite quickly for a trend move.
-
@dalkungen Ok. Do you have any initial project to begin with?
-
@l-andorrà I am just using a simple condition with MA in this test to figure out how i can make the second "block" of trades to execute only after SL has been moved to BE. Currently i put in the 'Check trades count' to limit trades until it works.
As you can see i tried to just link the 'Break even point' to next set of trades.
-
@dalkungen You need to disconnect blocks 12 and 13. In order to do that. You should create a boolean variable controling when break even happened and connect it below vblock 12. Then add a new condition block on top of block 13 pushing that the variable is active.
And don't forget to reinitiate the variable when necessary.
-
@l-andorrà Hi again. Thanks for you comments. I tried to create the Condition after block 12 but with my limited knowledge of programming... what shall i write as the IF statement? i was trying to find in the name of SL moved to BE in the MetaEditor but no luck. The example in the picture is wrong but just so you can see if i am on the right way.
Do i need another block between 24 and 12? to push block 14 or will that be automatic if condition in block 24 is true?
Also, when you said i need to reinitiate, how do i do that?
ps, i deleted block 13 Check trades count as that is what i want to avoid having there but had it there before just to make it work at all.
I tried with a flag as well but couldnt get that to work.
Thanks again

-
@dalkungen I didn't want to recommend the 'orange' condition block, but the 'yellow one'. Can you please share the link of your project instead of just a screenshot?
-
@l-andorrà https://fxdreema.com/shared/75KIKIb1c
updated with variables: https://fxdreema.com/shared/qeEcwfUL
but now it doesnt work in the MT4 strategy tester... -
@dalkungen I'm afraid I'm not a programmer so I have no idea what block 24 is doing in any case. Are you sure you need them?
-
@l-andorrà
No not in current state... i posted the link too early. Tried to update it here below. I wanted to create the calculation where StopLoss is moved to Open price/BreakEven and have that as a condition for next trade to open. So no new trade is opened before SL is moved to BE.
Thanks for looking at it ealier though, i am learning from it. I will keep trying. -
@dalkungen There is an easy alternative. Just create a boolean variable. Move it from false to true after the BE move. Then, in a different tree block, use a consition block on top of it requiring the variable to be true. Below it you can use then any other conditions required to open the new trades.
-
@l-andorrà ah ok now i understand. Sounds easy enough. I work with the Turn ON blocks after.
Many thanks -
@dalkungen You're welcome.