Creation of new variables by the EA.
-
Hi.
I am designing an EA, with a grid strategy.
The EA, I put n orders for sale and n for purchase, expecting a profit. I call this a series.
The EA will put more than one series.
I want to control the profit by series so that this is closed.
As I cannot determine if the system will place 1, 2, 3 .. or 100 series.
I need the EA to create new variables for me every time it creates a new one, and to delete them when the series closes upon reaching the profit. (system1, system2,… .system100)
With this I intend to create a loop, where it verifies the unrealized profit for each variable.
If you pass this block, it will execute the blocks that hang from it and re-execute the unrealized profit block with the following variable "system2", until all systems are evaluated.
My doubts.
1- How to create and delete new variables as needed.
2- How to make the loop. -
@cesardefez This is a fascinating question. I'm also interested in it. Although I'm not a coder i guess the obly way to get that is by using custom code. Are you roar or miro reading this, please?

-
hola . no entiendo tu pregunta. según google translator, ¿Estás rugiendo o miro leyendo esto, por favor? :).
-
hola,
voy a seguir con mis reflexiones.
inicializar la variable en principio no debe de ser difícil,
cuando se cumpla una condición, colocamos una caja Custom MQL code,

En este ejemplo no se si funcionaria, al querer nombrar la variable con una parte fija "sytem" y otra variable que provenga de un contador (n+1). El problema lo veo que la variable está definida, pero no en fxdream (variables),

¿se puede utilizar una variable no definida por fxdreeam?
¿como seria mas rapido el EA, intentar definir la variable cuando se necesite, o crearlas todas ( sytem_1...system_n) aunque nunca se necesiten?.supongo que lo más fácil es crear las todas, con valor falso.
conforme se necesiten se modifica su valor a true.
cuando se lanza el primer sitema, sytem_1, coje el valor true.
si sytem _n = true entonces se utiliza el filtro grupo = "n", para ese sistema.Pero entonces necesito comprobar el valor de todas las variables sytem_n, y coger la primera que este en false, para modificar a true y utilizarla para el nuevo sistema. ¿como se podria hacer esto último?
-
@cesardefez said in Creation of new variables by the EA.:
hola . no entiendo tu pregunta. según google translator, ¿Estás rugiendo o miro leyendo esto, por favor? :).
Estoy pidiendo a roar (el usuario) o a miro (el otro usuario) si pueden resulver tu duda.
Por otro lado, tal como digo en mi post en inglés, no puedo darte una respuesta porque lo que pides es cosa de programadores, cosa que yo no soy. Por eso pedía la ayuda de estos dos usuarios, ya que ellos síque lo son. Te recomiendo que continues el hilo en inglés o ambos te ignorarán, ya que no hablan español. -
ok gracias. lo seguiré en inglés.
-
I leave you the link of the project, explaining what it does and the problems I find.
thanks -
Hi. It seems to me that I buy myself when it comes to expressing what I need. I will try to do it as simple as possible.
I need to check the unrealized benefit, filtered by group #.
groups # do not have to always be the same.For example, I have orders with these groups at the moment.
group 1
group 3
group 4
group 6a total of 4 non-consecutive groups to filter. (could be more than 4 groups).
I pass the link to the example. What would it take to make it work?
https://fxdreema.com/shared/Jdp7P3qXc
thank you -
@cesardefez The easiest answer coming to my mind right now is simply creating 4 separated 'for each trade' block trees. Each one counting the profit of a different group. Then you can use a variable to store every result for the EA to use them later. Just an idea.
-
Thank you, I missed your help. always highly valued.
It would be a solution if the number of groups were always the same.
but my EA can create more or less groups.
In the example I have put with groups 1,3,4,6. I put the groups alternate, because at some point the groups 2 and 5 existed and were closed, at some point there were 5 or six groups, as well as at some point there may be more groups (4,6, .... n) -
@cesardefez But you can also specify group numbers in each 'For each trade' block. Including more than one comma separated.
-
It's interesting, I didn't know that you can put multiple groups, separated by commas.
but the problem is that I don't know what n groups I have running.
if there is any way to check the group of all open operations, create a list and save them in a text variable. you could use that variable.
example: variable .... open_grups = 1,3,6,8,9,12
If after group 6 is closed then update open_grups = 1,3,8,9,12, in the same way if a new group is opened (2 for example). it becomes update open_grups = 1,2,3,8,9,12
open_grups would use it as a variable in the group field of the unrealized benefits block. -
@cesardefez In that case you need a loop searching for that information. I'm afraid loops are not my field of expertise. Maybe mr roar would be so kind to help?