Lotage calculation between two lines (Solved)
-
Hello! Could someone inform me how to do the following:
I want to put two horizontal lines, one would be the entry and the other the Stop Loss with these two lines drawn and identified (entry = ORD and stop Loss = SL)
once these two lines are drawn, in a panel pressing a button (Buy or SELL) I calculate the distance in pips and with% of the balance I generate the operation of SELL or BUY with the appropriate lot. -
@xyon126 Are those lines inserted manually or automatically by the EA in the chart?
-
@l-andorrà The initial idea is to manually draw two horizontal lines or, failing that, only one as Stop Loss and that by pressing a button that calculates the necessary lots for me between that line and the current price, there will be an operation with the specified percentage (included within the order) and the other option that I think is not possible with a preset amount of € or $ as well. In this way I open trades with the lot already calculated automatically with the EA.
-
@xyon126 You will need to search for those objects and then store that info in different variables. You can fond some useful info here:
https://fxdreema.com/forum/topic/4867/select-object-by-name-several-objects/4
-
Ayuda, he llegado a este punto pero creo que esta todo mal, me salen muchos errores.
https://fxdreema.com/shared/kGH1BPTad -
@xyon126 Primero necesitas colocar un segundo bloque en la pestaña 'on init' para que se active correctamente el bloque suelto que tienes ahora. Luego veo que otra vez pones todos los bloques en la de 'on timer'. You no soy muy partidario de usarla. ¿A ti ten funciona bien en otros EAs? Lo digo porque cuando la he usado you siempre me hace cosas raras? ¿Ralmente lo necesitas todo ahí?
-
@l-andorrà Hola. Lo he modificado y he puesto varios bloques segun lei tambien de un post de miro1360 sobre lineas y objetos pero me sigue dando error con las variables y constantes. Sobre lo de la pestaña Timer si lo cambio a la del Tick me he dado cuenta que no se regenera hasta que se genera un nuevo tick cosa que con Timer es casi inmediato. Aqui esta el status actual :
-
@xyon126 Pues me temo que no te puedo ayudar más.
Veo ahí dos bloques de custom code que no tengo idea de lo que hacen. Me temo que te hace falta un programador para que te diga por qué te salen esos errores. Lo siento. 
-
@l-andorrà Hello Andorrá! I assume you mean these blocks:

What these two blocks do is to check that the lot obtained if it is less than that of the variable "LOT" that is taken by default that of the variable, that is, if I obtain by calculation 0.01 lots as it is less than 0.04, 0.04 will be placed default batches.(This code is from @pontedruse)
I have varied to simplify it and instead of 2 drawn lines that I measure between a line and the average price, many errors have been solved but I still get this error, how can I eliminate it? Is the rest okay?

Here is the last state:
https://fxdreema.com/shared/gPlEs4P3c -
@xyon126 The forst error is telling that a Constant called 'Distance' should be used somewhere. I see you have a variable called like that in use there. I don't understand why a constant is required whaen a variable is the correct thng to do.
About the second one, can you please tell what type of Constant is that?
-
@l-andorrà I have managed to find and solve the errors but it does not calculate the lot and it does not create the Stop Loss. Where can the error be?. Where can the error be?. Please help.:
Here is the last state:
-
@xyon126 I guess there is something happening in those custom code blocks. I'm afraid I'm not a prgrammer so I cannot offer you an answer. All other blocks are correct AFAIK.
-
@l-andorrà I have tried the EA without those lots and the same thing happens to me, the problem must be in the management of obtaining the distance in the graph and entering it in the SELL or BUY block
-
@xyon126 I'm not sure, but I guess the problem then should be that variable called 'distancia precio'. Are you sure it is accepted for that box? You should choose any of the options of the display menu there. However you 'imposed' anew variable that maybe cannot be recognised by that block.
-
@l-andorrà It is just what I do not know that is why I am trying, if someone knows how to do it it would be of great help since the last state is tests