Limit Maximum symbols trading.
-
Friends, I'm trying to limit a max of trades per symbol.
For example, I can put 28 currencies to trade, but if I define that I want a maximum of 3 trading, the EA should respect it and it is not respecting it.
Can anyone see in this project where I'm getting the logic wrong? -
@roar you can help me here ?
-
The only I can see now is by crating a loop searching for every open chart separately and then checking that limit. AFAIK you will need custom code doing that.
-
@l-andorrà
I'm believing it might be a BUG for the following reason.
Reading the Logic:- Loop through all the assets being requested.
- Save these assets across all interactions in a variable.
- Check if "There is any buy or sell position" for each of the assets.
- Check if the Maximum Defined Symbols is lower than requested. If it is lower 1 time per bar buy or sell.
I believe the logic is correct.
For this reason I believe there is a BUG. -
@fxDreema you can help here?
-
hi
instead of looping through every symbol to limit the trades just loop through trades
before opening new trade just check if The new Trade Symbol has already 3 open positions or not and then open or cancel the trade -
@aliso
Can you give me an example of how to do this?
From what I understand your solution will not work, because I am working with multi-markets so I will have the 28 forex currency pairs in the key to open trades.
Imagine that I set the EA to allow only 3 pairs to trade, so I set the number 3 in the condition.
If I have for example:
1 EURUSD trade.
1 GBPUSD trade.
1 AUDUSD trade.
So if the EA tries to open +1 trade, no matter what currency it is, it will not be allowed because 3 simultaneous open trades have already been reached, even if they are different currency pairs.
Did you understand? -
I also used this block, which I understand would make it a lot easier, but from what I've seen it's not working well either.

-
I believe I found the problem, all this has to be done in "On Trader" and not in "On Tick"
-

is correct to solve this problem, thanks for all @aliso @l-andorrà @roar -
@OntradingX your original example has a working checkup with the increasing variable, you are just not checking all symbols at once.
This structure should work. Use a 1-cycle loop block to control the flow: first go through symbols, then continue with the currently selected symbol

-
@roar
One question... when I use the "Set current Market" block and below it I connect a variable block, it is saving 1 variable at a time doing 1x the loop in each asset individually, correct?
Do I have to use this same variable in all the blocks that have the "symbol" field?