Formula block - count trades of certain Group
-
Hi,
I use formula for counting history trades so i can set lot size for future pending trades of certain group#.
How can I count trades of other group# of trades in the same EA?
Thnx
BR
-
I can see you start counting when the EA is started... or at least it looks like this. Actually you can count over the past trades and orders using "For each...." blocks. Well, now I realized that I should add option in "For each Closed Trade" to not go to very old history trades, but at least you can specify exact amount of past closed history trades to work with.
I can suggest to define and use a variable (click Variables) instead of Formula's result variable.
Here is a little example of how to calculate lot sizes of buys and sells: http://fxdreema.com/shared/bvrTBQFKb
Or even better with this one: http://fxdreema.com/shared/NwqfdGorc
this example is better because you loop trades once, and for each of them you ask for some of it's properties (in the case - it's type) before incrementing other parameter. So you can actually loop all available trades from all groups, and within the loop to check it's group number.... I think you will get it
Read the information of these pink blocks to understand how they work. You will probably realize how this second properties panel works.
I used "OrderLots()" which is a native MQL4 function that returns the lot size of the currently loaded trade, but you can also use "Formula" or "Condition (+Adjust field)" or "Modify Variables" to modify a variable. In these blocks the given parameter (for example lot size) is hidden somewhere in the pink "(in loop)...." category.