Divergences MACD Screener

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #149256 quote
    Lily Rios
    Participant
    Senior

    Buenos dias, me gustaria saber como transformar este indicador en un proscreener.
    saludos.
    https://www.prorealcode.com/prorealtime-indicators/macd-divergences-on-price-and-indicator/

    div.png div.png
    #154818 quote
    robertogozzi
    Moderator
    Master

    Ahí tienes:

    ///////////////////////////////////////////////////////////
     
    // MACD divergences on price
    //by Jose Callao
    // twitter @jose7674
    // attach this indicator to the chart
     
    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
     
    //using any other indicator is as easy as changing the values
    miMACD = exponentialAverage[12](close) - exponentialAverage[26](close)
    Signal = 0
    IF (BarIndex > 10+1+N) THEN
     
    //we look for bearish divergences
    IF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THEN
    extremum2=miMACD[1]
    extremum1=highest[N](miMACD)
     
    preciomax2=close[1]
    preciomax=Highest[N](close)
    IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
    for i=1 to N
    if close[i]=preciomax[1] then
    //zz=i
    Signal = 2
    //drawsegment (barindex[1], close[1], barindex[zz], close[zz]) coloured(200,0,0)
    endif
    next
     
    endif
    endif
     
    //we look for bullish divergences
    IF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THEN
    extremum22=miMACD[1]
    extremum11=lowest[N](miMACD)
     
    preciomin2=close[1]
    preciomin=lowest[N](close)
     
    IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
    for i2=1 to N
    if close[i2]=preciomin[1] then
    //zz2=i2
    Signal = 1
    //drawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)
    endif
    next
    endif
    endif
    endif
    SCREENER[Signal](Signal AS "1=↑, 2=↓")
    #154859 quote
    Lily Rios
    Participant
    Senior

    Buenos dias, el código al parecer no esta completo.

    En la linea 33 falta un operador igual mayor o menor : IF (miMACD[1] extremum22=miMACD[1]….

    En la linea 38 también falta algún operador para la variable preciomin2: IF(extremum22>extremum11 AND preciomin2 for i2=1 to N

    En la linea 45 la función next muestra error derivados de los errores anteriores.

    saludos,

    Captura-de-pantalla-2020-12-09-a-las-10.45.51.png Captura-de-pantalla-2020-12-09-a-las-10.45.51.png
    #154862 quote
    robertogozzi
    Moderator
    Master

    El problema es causado por la palabra REM, que significa comentar, reemplazarlo con RME o lo que sea, incluso si no está al principio.

    #154878 quote
    Lily Rios
    Participant
    Senior

    Gracias por corregirlo, ahora si funciona estupendamente.

    #180297 quote
    betty
    Participant
    New

    buenos dias!

    si quisiesmos hacer lo mismo con el rsi, seria suficiente sustituir la palabra MACD por RSI ?? igual es una tonteria de pregunta pero no se de programacion.

    Y si quisiesemos sumar los dos?

    #180301 quote
    robertogozzi
    Moderator
    Master

    Sí, puede dejar el nombre de la variable como está, solo cambie el indicador:

    miMACD = RSI[14](close)

    Puedes crear otro con el Momentum, o con Willims R%, etc.

    #215017 quote
    Nicolas
    Keymaster
    Master

    Según lo solicitado, aquí está el código que combina este filtro: https://www.prorealcode.com/prorealtime-market-screeners/evening-morning-stars-screener/ con el código de divergencias publicado anteriormente:

    //Author: Boursomaniac
    //Date: 19-02-2017
    
    // Data Set-up
    BaseCandle = 0
    Open0 = Open[BaseCandle]
    Close0 = Close[BaseCandle]
    Open1 = Open[BaseCandle + 1]
    Close1 = Close[BaseCandle + 1]
    Open2 = Open[BaseCandle + 2]
    Close2 = Close[BaseCandle + 2]
    Open3 = Open[BaseCandle + 3]
    Close3 = Close[BaseCandle + 3]
    
    // Control height
    DojiBody = ABS(Close1-Open1)
    HeightLong = 7*DojiBody
    
    // ++++++++++EVENING STAR++++++++++++
    // Calcul height candelstick 2 and 2
    CandleElong0 = ABS(Close0-Open0)
    CandleElong2 = ABS(Close0-Open0)
    
    // Validate Candlestick color + position
    CandleE0 = Open0 > Close0 And Open0 < Close1 AND (CandleElong0>=HeightLong)
    CandleE1 = Open1>Open0 AND Close1>Close0 AND Close1>Close2 AND Open1>Open2
    CandleE2 = Open2 < Close2 And Close2 > Close3 And Open3 < Close3 AND (CandleElong2>=HeightLong)
    
    EvStar = CandleE0 AND CandleE1 AND CandleE2
    
    
    // ++++++++++MORNING STAR++++++++++++
    // Calcul height candelstick 2 and 2
    CandleMlong0 = ABS(Close0-Open0)
    CandleMlong2 = ABS(Close0-Open0)
    // Validate Candlestick color + position
    CandleM0 = Open0 < Close0 And Open0 > Close1 AND (CandleMlong0>=HeightLong)
    CandleM1 = Open1<Open0 AND Close1<Close0 AND Open1<Open2 AND Close1<Close2
    CandleM2 = Open2 > Close2 And Close2 < Close3 And Open3 > Close3 AND (CandleMlong2>=HeightLong)
    
    //Morning Star
    MornStar =  CandleM0 AND CandleM1 AND CandleM2
    
    Condition = (EvStar Or MornStar)
    
    ///////////////////////////////////////////////////////////
     
    // MACD divergences on price
    //by Jose Callao
    // twitter @jose7674
    // attach this indicator to the chart
     
    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
     
    //using any other indicator is as easy as changing the values
    miMACD = exponentialAverage[12](close) - exponentialAverage[26](close)
    Signal = 0
    IF (BarIndex > 10+1+N) THEN
     
    //we look for bearish divergences
    IF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THEN
    extremum2=miMACD[1]
    extremum1=highest[N](miMACD)
     
    preciomax2=close[1]
    preciomax=Highest[N](close)
    IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
    for i=1 to N
    if close[i]=preciomax[1] then
    //zz=i
    Signal = 2
    //drawsegment (barindex[1], close[1], barindex[zz], close[zz]) coloured(200,0,0)
    endif
    next
     
    endif
    endif
     
    //we look for bullish divergences
    IF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THEN
    extremum22=miMACD[1]
    extremum11=lowest[N](miMACD)
     
    preciomin2=close[1]
    preciomin=lowest[N](close)
     
    IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
    for i2=1 to N
    if close[i2]=preciomin[1] then
    //zz2=i2
    Signal = 1
    //drawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)
    endif
    next
    endif
    endif
    endif
    
    
    
    SCREENER[Condition and signal] (Signal AS "1=↑, 2=↓")
    
    lee thanked this post
    #215021 quote
    lee
    Participant
    New

    Thank you so much Nicolas for taking the time to combine these 2 screeners, I very much appreciate it. Hope this is useful for other traders also.

    Many thanks again.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Divergences MACD Screener


ProScreener: Buscadores de Mercado y Rastreo

New Reply
Author
author-avatar
Lily Rios @lily_rios Participant
Summary

This topic contains 8 replies,
has 6 voices, and was last updated by lee
2 years, 9 months ago.

Topic Details
Forum: ProScreener: Buscadores de Mercado y Rastreo
Language: Spanish
Started: 11/02/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...