identify group related to entry count and the age
-
How to identify group related to entry count and the age :
Assume have 3 group need in identify.
Example – entry count = 9 = post 1,2,3,4,5,6,7,8,9.
Group 01 = 1, 2, 3 (post 1 = entry that oldest)
Group 02 = 4, 5, 6
Group 03 = 7, 8, 9 (post 9 = entry that youngest)If case further position closed for entry 1, 5, 7 and the next new entry is A, B, C.
Group condition will change like :Group 01 = 2, 3, 4 (post 2 = entry that oldest)
Group 02 = 6, 8, 9
Group 03 = A, B C (post C = entry that youngest)I need the solution please.....
-
Group number is used to group trades/orders in the project only when needed. And it's needed when you want to control one group with some rules and other group with different rules. If all trades/order are to be controlled in the same way, then no Group is needed (all should have the same Group).
Group number is associated to the trade/order when it is created. Then it doesn't change in MT4 (but it can change in MT5).
Then, you can have 20 trades, 10 of them from Group 1 and the other 10 of Group 2.In all the blocks that are designed to load or check certain trades and orders you can choose which Group to work with, so within the same project you can control first 10 trades in one way and the other 10 with another block in a different way. Again, only if really needed.
Maybe I'm starting to understand what you want to do... maybe you want to filter trades by their age, and this can happen using "Start trades loop" block (I just renamed it to "For each Trade").
By default it loads trades starting from the newest (youngest) and it continues to the last trade that has the same market, Group and type as specified. But there are two other options - [Skip "n" trades] and [Not more than "n" trades] - and with these options you can skip and limit trades, so you can for example skip trades 1 and 2, then load 3, 4 and 5. For this set the parameters to skip 2 trades and to load not more than 3 trades.
-
Get this for example (don't try it on Real!), try it on backtest: http://fxdreema.com/shared/CVreVRMR
10 trades are created with ticket numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
I want to close only trades 8, 7 and 6, so in "For each Trade" I skip 2 trades and work with not more than 3 trades. Skipped trades are of course those with ticket numbers 10 and 9.
-
But the problem.
How to determint if want to close only one post for certain group.
the post felt best to close based on condition.
-
Magic number attribute is used for Group numbers (Magic number=MagicStart+Group) and magic numbers cannot be modified at least in MQL4 - here is the function to modify trade/order and there is nowhere Magic number parameter: http://docs.mql4.com/trading/ordermodify
In other words, if a trade is created with magic number = 1000, it stays with it forever.But you can always close the N-th trade.
-
It look like need sub loop after loop.
1st loop
- skip 10
- not more than 10.
2nd loop
- skip = EMPTY
- not more than = 1 ( best entry to closed base on condition)
is it possible ???....
-
__Magic number attribute is used for Group numbers (Magic number=MagicStart+Group) and magic numbers cannot be modified at least in MQL4 - here is the function to modify trade/order and there is nowhere Magic number parameter: http://docs.mql4.com/trading/ordermodify
In other words, if a trade is created with magic number = 1000, it stays with it forever.But you can always close the N-th trade.[/quote:iv9utn2o]
OK I understand.. I try... thank..
-
Still not work..
Any more idea...

-
Abu, I found it hard to understand what you want to do. If you have some project example...
-
It look like need sub loop after loop.
1st loop
- skip 10
- not more than 10.
2nd loop
- skip = EMPTY
- not more than = 1 ( best entry to closed base on condition)
is it possible ???....
"Not more than 10" means that up to 10 trades can be closed after the first ones were skipped. If you have 20 trades the second half will be closed.
What is that condition and where it is located?
-
Here attach sample for your reference..
......
001.mq4 -
Here one more sample for your understand..
......
002.mq4 -
If you have 10 trades, you want to close for example trades 10, 7 and 4?
-
yap... Not specify by no actually..
-
Maybe I should create some pattern to be able to load trades X, Y and Z, or each Nth trade, but now I can suggest this: http://fxdreema.com/shared/H8iJIEH6
The loop is repeated 3 times, but because after a trade is closed, the order is changed, I use variable to adjust the skip parameter.
-
OK.. I check it..
-
Just added [Every "n" trade] option to "For each Trade", now only this block is enough.