error codigo linea tendencia
Forums › ProRealTime foro Español › Soporte ProBuilder › error codigo linea tendencia
- This topic has 4 replies, 2 voices, and was last updated 7 months ago by dagilo1975.
-
-
03/27/2024 at 11:44 AM #230565
Buenos dias, alguien podria revisarme el codigo. No consigo que la linea de tendencia modifique el punto de la derecha para que se grafique correctamente
defparam drawonlastbaronly = true
numerobarraderechalt0=0
numerobarraizquierdalt0=barindex
preciobarraderechalt0 = log(low[numerobarraderechalt0])
preciobarraizquierdalt0 = log(low[numerobarraizquierdalt0])//determina el valor minimo para el punto de la izquierda de la linea de tendencia
for ilt0=numerobarraizquierdalt0 downto numerobarraderechalt0 do
if log(low[ilt0])<preciobarraizquierdalt0 then
preciobarraizquierdalt0 = log(low[ilt0])
numerobarraizquierdalt0 = ilt0
endif
next//Desplaza el punto de la derecha desde el punto de la izquierda hacia la ultima barra en los minimos que sean inferiores al valor de la recta para cada barra
for ilt0= numerobarraizquierdalt0-1 downto numerobarraderechalt0 do
valorrecta=((10* EXP((((log(low[numerobarraderechalt0])-log(low[numerobarraizquierdalt0]))/(barindex[numerobarraderechalt0]-barindex[numerobarraizquierdalt0]))*(barindex-barindex[numerobarraderechalt0]))+log(low[numerobarraderechalt0])))/10)
if log(low[ilt0])< valorrecta[ilt0] then
preciobarraderechalt0 = log(low[ilt0])
numerobarraderechalt0 = ilt0
endif
next//grafica linea de tendencia y valores de las mismas
DRAWLINE(barindex[numerobarraizquierdalt0], low[numerobarraizquierdalt0], barindex[numerobarraderechalt0], low[numerobarraderechalt0])
DRAWPOINT(barindex[numerobarraizquierdalt0], low[numerobarraizquierdalt0], 3)
DRAWPOINT(barindex[numerobarraderechalt0], low[numerobarraderechalt0], 2)
valorrecta=((10* EXP((((log(low[numerobarraderechalt0])-log(low[numerobarraizquierdalt0]))/(barindex[numerobarraderechalt0]-barindex[numerobarraizquierdalt0]))*(barindex-barindex[numerobarraderechalt0]))+log(low[numerobarraderechalt0])))/10)return valorrecta as “valorrecta”
03/27/2024 at 4:45 PM #230596Hello… Use the ‘Insert PRT Code’ function to add code to the post or the language translation will replace your variables with different names and won’t be consistent in doing so, then the code won’t run. I had to change it just to make it work and understand a little bit. I made it work, I don’t know if it’s right. druby
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253defparam drawonlastbaronly = truerightbarnumberlt0 = 0leftbarnumberlt0 = barindexrightbarlt0 = log(low[rightbarnumberlt0])leftbarpricelt0 = log(low[leftbarnumberlt0])//Determine the minimum value for the point on the left of the trendlinefor i = leftbarnumberlt0 downto rightbarnumberlt0 doif log(low[i]) < leftbarpricelt0 then // if this trueleftbarpricelt0 = log(low[i]) // update valueleftbarnumberlt0 = i // update barendifnext//Move the point on the right from the point on the left to the last bar at the minimum that is lower than the value of the line for each barfor i = leftbarnumberlt0-1 downto rightbarnumberlt0 doA = low[rightbarnumberlt0]B = low[leftbarnumberlt0]C = barindex[rightbarnumberlt0]D = barindex[leftbarnumberlt0]E = barindex-barindex[rightbarnumberlt0]rightbar = ( 10 * EXP( ( ( (log(A)-log(B) ) / (C-D) ) * (E) ) ) + log(A) ) / 10if log(low[i] )< rightbar[i] then////////////////////rightbarpricelt0 = log(low[i])rightbarnumberlt0 = iendifnext//trend line chart and values of the samex1 = leftbarnumberlt0x2 = rightbarnumberlt0DRAWLINE(barindex[x1], low[x1], barindex[x2], low[x2])DRAWPOINT(barindex[x1], low[x1], 3)DRAWPOINT(barindex[x2], low[x2], 2)A = low[x2]B = low[x1]C = barindex[x2]D = barindex[x1]E = barindex-barindex[x2]r = ( 10 * EXP( ( ( (log(A)-log(B) ) / (C-D) ) * (E) ) ) + log(A) ) / 10return low//,valorrecta as "valorrecta"03/28/2024 at 1:43 PM #230656Druby Muchas gracias por la contestación, pero el código no actúa como tengo en mente. voy a intentar hacer una explicación de lo que pretendía con mi código.
1º el punto de la izquierda busca el low mas bajo (teniendo ahora una recta entre el low mas bajo (punto de la izquierda) y el low de la ultima barra (punto de la derecha))
2º ahora preguntamos ¿hay algún low por debajo de la linea de tendencia que genera el punto de la izquierda y el punto de la derecha?
a) Si, ahora desplazamos el punto de la derecha hacia el punto de la izquierda, siendo nuevo punto de la izquierda el el low que ha marcado que era inferior (repitiendo el punto 2 hasta que la condicion sea NO)
b) No, fin del bucle
Atentamente, David
04/03/2024 at 3:12 PM #230998Hello..
I’ve been looking at this over the weekend. I couldn’t determine if the errors were related to math, algorithm logic, or the way PRT executes code.
I decided to start from scratch and try to make something work even if it’s not exactly what is required. However, it may be easier to understand/modify the code from a working position.
I couldn’t fully understand the version of the logarithmic/linear equation you used, so I used a linear/linear equation for the calculation, which is much simpler and could be replaced later if needed.
The logic of the program took a while, but it got easier, with the math under control. But there were also some execution issues to overcome.
Looking at the indicator’s movement, I can see that there are more things to do on the logical side, as usual! Under various conditions, the line changes abruptly. The movement of the points on a new breakout of the trendline may require “some” delay when the points end very close together.
Also, all this numerical calculation will slow down the program, but the parts could be optimized. For example, if the trendline point of the next new bar is known before the next bar arrives, then it would be a simple calculation to determine if it would break the trendline, therefore it would not require a loop of point movement etc., just the next point for the verification of the next bar.
Just speculating on more modifications!
This version is generalized so that it can be used for low or high trend lines using two instances of the indicator and setting the ‘switch’ variable to ‘1 or 0’ and adjusting the colour of the High/Low line via the settings menu if it is a standalone indicator, or hidden, if it is added to the price panel.
Take a look around and see what fits, etc.
druby
04/12/2024 at 8:33 AM #231430muchas gracias por tu ayuda, finalmente he encontrado la errata, No habia indicado la posicion dentro de la linea de tendencia
valorrecta=((10* EXP((((log(low[numerobarraderechalt0])-log(low[numerobarraizquierdalt0]))/(barindex[numerobarraderechalt0]-barindex[numerobarraizquierdalt0]))*(barindex[ilt0]-barindex[numerobarraderechalt0]))+log(low[numerobarraderechalt0])))/10)
Atentamente, David
-
AuthorPosts
Find exclusive trading pro-tools on