Hola,
En la operativa que hago, tengo que revisar más de 50 acciones todos los días. Una de las variables que miro es si el trade tiene un objetivo amplio o corto. Esto lo hago manualmente poniendo la regla y midiendo el porcentaje. Un trabajo que pienso que se podría automatizar pero, que no se me ocurre por donde empezar.
Mi pregunta es si esto que propongo se puede hacer o si alguien hizo un indicador parecido que le indique automáticamente este porcentaje de posible beneficio insertado en el precio y a la vez que indique el soporte y la resistencia más próxima.
Muchas gracias.
¿Puede dar un ejemplo?
¿Quiere introducir un precio y necesita calcular un porcentaje de beneficio potencial en función de qué? ¿O escribes el porcentaje y el indicador solo tiene que trazar una línea correspondiente a ese porcentaje?
Hola
Quizás este código te pueda valer. Lo que hace es localizar los puntos pivote.
Mediante la configuración podrás marcar si es una entrada larga/corta y el ratio entre TP y Stop loss.
//defparam drawonlastbaronly=true
//------------------------------------------------------------//
//------------------------------------------------------------//
prd = 5 //periods for pivot calculation
pivottype=1 //method to calculate pivots
ratio=2 // ratio reward/risk
tradetype=1 // 1= long trade / 0= short trade
//------------------------------------------------------------//
if pivottype then
src1 = low
src2 = high
else
src1 = min(open,close)
src2 = max(open,close)
endif
//------------------------------------------------------------//
/////pivots low
if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
$plow[z+1] = src1[prd]
$plowidx[z+1] = barindex[prd]
z=z+1
drawpoint(barindex[prd],src1[prd],2)coloured("red",100)
endif
/////pivots high
if src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then
$phigh[t+1]=src2[prd]
$phighidx[t+1]=barindex[prd]
t=t+1
drawpoint(barindex[prd],src2[prd],2)coloured("blue",100)
endif
//------------------------------------------------------------//
if islastbarupdate then
dist=abs($phigh[t]-$plow[z])
if tradetype then
TP=$phigh[t]+ratio*dist
drawsegment($phighidx[t],TP,barindex+10,TP)coloured("green")style(line,2)
drawsegment($plowidx[z],$plow[z],barindex+10,$plow[z])coloured("red")style(line,2)
drawsegment($phighidx[t],$phigh[t],barindex+10,$phigh[t])coloured("blue")style(dottedline,2)
else
TP=$plow[z]-ratio*dist
drawsegment($plowidx[z],TP,barindex+10,TP)coloured("green")style(line,2)
drawsegment($plowidx[z],$plow[z],barindex+10,$plow[z])coloured("blue")style(dottedline,2)
drawsegment($phighidx[t],$phigh[t],barindex+10,$phigh[t])coloured("red")style(line,2)
endif
endif
return
Ivan,
Me parece un código estupendo para utilizarlo como base. En cuanto tenga algo avanzado lo colgaré por si a alguien más le es útil.
Muchas gracias.
He estado dandole vueltas al tema del indicador. Y me he acordado de que está el indicador PRT Bands que hace casi lo mismo que queria hacer yo. Así que utilizaré ese.
Muchas gracias por la ayuda.