Estaría muy agradecido si me pudiesen adaptar este indicador MACD a un indicador de divergencia Bollinger %B.
https://www.prorealcode.com/topic/macd-divergence-indicator-with-histogram/#
Gracias,
Aqui tienes la divergencia entre el indicador %bollinger y el precio.
N=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators
//% Bollinger
bollUp=BollingerUp[20](close)
bollDw=BollingerDown[20](close)
Pboll = (close-bolldw)/(bollUp-bollDw )*100
IF (BarIndex > 10+1+N) THEN
///divergencia bajista
IF (Pboll[1]>Pboll AND Pboll[1]>Pboll[2]) THEN
extremum2=Pboll[1]
extremum1=highest[N](Pboll)
preciomax2=close[1]
preciomax=Highest[N](close)
IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
for i=1 to N
if Pboll[i]=extremum1 then
zz=i
drawsegment (barindex[1], Pboll[1], barindex[zz], Pboll[zz]) coloured(200,0,0)
endif
next
endif
endif
///divergencia alcista
IF (Pboll[1]<Pboll AND Pboll[1]<Pboll[2]) THEN
extremum22=Pboll[1]
extremum11=lowest[N](Pboll)
preciomin2=close[1]
preciomin=lowest[N](close)
IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
for i2=1 to N
if Pboll[i2]=extremum11[1] then
zz2=i2
drawsegment(barindex[1], Pboll[1], barindex[zz2], Pboll[zz2]) coloured(0,200,0)
endif
next
ENDIF
ENDIF
endif
return Pboll as "%Boll", 0 as "0"
Good ask and better answer. A little treasure. Thanks.
Buena pregunta y mejor respuesta. Un pequeño tesoro. Gracias.
@P. Marlowe
Publica solo en el idioma del foro en el que publicas. Por ejemplo, inglés solo en foros en inglés y español solo en foros en español. Gracias 🙂
Gracias Iván:
Lo estuve probando y cumple mis expectativas, ya te seguía en algunos videos tuyos por cierto muy buenos para intentar coger algo de conocimientos de este mundo maravilloso que es la bolsa.
No sé si formulo esta pregunta bien, o la tendría que formular en el apartado de Screeners.
Le voy a molestar una vez más, se podría adaptar el indicador anterior a un Screener Bollinger %B también. Teniendo en cuenta el archivo adjunto.
Mejor en el hilo de screeners.
A la hora de compartir código tienes un botón para introducir el código de PRT.