MACD con filtro su superamento massimo/minimo precedente

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #142124 quote
    fabio_effe
    Participant
    New

    Ciao a tutti, sono nuovo nel forum e sono novizio anche sulla piattaforma, motivo per cui mi scuso per eventuali imprecisioni o se dovessi chiedere temi già trattati.

    Vi chiedo una mano se possibile in merito ad un indicatore che vorrei realizzare; di seguito i dettagli:

    vorrei realizzare un MACD che tracci sul grafico segnali di acquisto o vendita (tramite le classiche frecce ad esempio) ma non ad ogni intersezione del macd, bensì vorrei cercare di “ripulirlo” da eventuali falsi segnali inserendo la seguente condizione:

    • segnale acquisto -> se rispetto all’intersezione del macd, nei successivi 5 giorni, il prezzo supera il massimo registrato nei 10 giorni precedenti all’intersezione
    • segnale vendita -> se rispetto all’intersezione del macd, nei successivi 5 giorni, il prezzo supera il minimo registrato nei 10 giorni precedenti all’intersezione

    in aggiunta (ma secondariamente) si potrebbe anche pensare ad uno screener con tali parametri.

    Cosa ne pensate?

    Grazie mille

    #142134 quote
    robertogozzi
    Moderator
    Master

    Non l’ho provato:

    Once n        = 10
    Once p        = 5
    Once CrossBar = 0
    Once HH       = 0
    Once LL       = 0
    Once CrossUP  = 0
    Once CrossDN  = 0
    Once Crossing = 0
    If Crossbar > 0 and (BarIndex - Crossbar) > p Then
       CrossBar = 0
       HH       = 0
       LL       = 0
       CrossUP  = 0
       CrossDN  = 0
       Crossing = 0
       Lcond    = 0
       Scond    = 0
    Endif
    a = MACD[12,26,9](close)         //Hysto
    b = MACDLine[12,26,9](close)  //MACD
    c = ExponentialAverage[9](b)   //Signal
    If CrossUP = 0 Then
       CrossUP = b Crosses Over   c
       If CrossUP Then
          Crossing = 1
          CrossDN  = 0
       Endif
    Endif
    If CrossDN = 0 Then
       CrossDN = b Crosses Under c
        If CrossDN Then
          Crossing = -1
          CrossUP  = 0
       Endif
    Endif
    If Crossing  <> Crossing [1] Then
       Crossbar = BarIndex
       HH = highest[n](high[1])
       LL  = lowest[n](low[1])
    Endif
    Lcond = CrossUP and Close crosses over  HH
    Scond = CrossDN and Close crosses under LL
    x = 0
    If Lcond then
       x = 1
    Elsif Scond then
       x = -1
    Endif
    RETURN x AS “Segnale”
    #142137 quote
    fabio_effe
    Participant
    New

    Grazie per la risposta.

     

    Ho aggiunto l’indicatore sul grafico (non in finestra separata) ma non vedo indicazioni.

    Mi sapresti dare una mano per favore?

    Grazie

    #142142 quote
    robertogozzi
    Moderator
    Master

    Questo va sotto, appena posso te lo modifico.

    fabio_effe thanked this post
    #142182 quote
    robertogozzi
    Moderator
    Master

    Questo va sul grafico:

    Once n        = 10
    Once p        = 5
    Once Offset   = 10 * pipsize
    Once CrossBar = 0
    Once HH       = 0
    Once LL       = 0
    Once CrossUP  = 0
    Once CrossDN  = 0
    Once Crossing = 0
    If Crossbar > 0 and (BarIndex - Crossbar) > p Then
       CrossBar = 0
       HH       = 0
       LL       = 0
       CrossUP  = 0
       CrossDN  = 0
       Crossing = 0
       Lcond    = 0
       Scond    = 0
    Endif
    //a = MACD[12,26,9](close)    //Hysto
    b = MACDLine[12,26,9](close)  //MACD
    c = ExponentialAverage[9](b)  //Signal
    If CrossUP = 0 Then
       CrossUP = b Crosses Over  c
       If CrossUP Then
          Crossing = 1
          CrossDN  = 0
       Endif
    Endif
    If CrossDN = 0 Then
       CrossDN = b Crosses Under c
        If CrossDN Then
          Crossing = -1
          CrossUP  = 0
       Endif
    Endif
    If Crossing  <> Crossing [1] Then
       Crossbar = BarIndex
       HH = highest[n](high[1])
       LL  = lowest[n](low[1])
    Endif
    Lcond = CrossUP and Close crosses over  HH
    Scond = CrossDN and Close crosses under LL
    If Lcond then
       DRAWARROWUP(barindex,low-offset) coloured(0,255,0,255)
    Elsif Scond then
       DRAWARROWDOWN(barindex,high+offset) coloured(255,0,0,255)
    Endif
    RETURN
    #142199 quote
    robertogozzi
    Moderator
    Master

    C’è un errore logico sopra. La versione corretta è questa:

    Once n        = 10
    Once p        = 5
    Once CrossBar = 0
    Once HH       = 0
    Once LL       = 0
    Once CrossUP  = 0
    Once CrossDN  = 0
    Once Crossing = 0
    ONCE Offset   = 100 * pipsize
    If Crossbar > 0 and (BarIndex - Crossbar) > p Then
       CrossBar = 0
       HH       = 0
       LL       = 0
       CrossUP  = 0
       CrossDN  = 0
       Crossing = 0
       Lcond    = 0
       Scond    = 0
    Endif
    //a = MACD[12,26,9](close)    //Hysto
    b = MACDLine[12,26,9](close)  //MACD
    c = ExponentialAverage[9](b)  //Signal
    CrossUP = b Crosses Over  c
    If CrossUP Then
       Crossing = 1
       CrossDN  = 0
    Endif
    CrossDN = b Crosses Under c
    If CrossDN Then
       Crossing = -1
       CrossUP  = 0
    Endif
    If (Crossing <> Crossing[1]) AND (Crossing <> 0) Then
       Crossbar = BarIndex
    Endif
    IF Crossbar > 0 THEN
       HH = highest[n](high[1])
       LL = lowest[n](low[1])
       IF (Not CrossUP) AND (Not CrossDN) THEN
          CrossUP = CrossUP[1]
          CrossDN = CrossDN[1]
       ENDIF
    ENDIF
    Lcond = (CrossUP and open < HH AND close > HH) OR (Close crosses over  HH)
    Scond = (CrossDN and open > LL AND close < LL) OR (Close crosses under LL)
    If Lcond then
       DRAWARROWUP(barindex,low-offset) coloured(0,255,0,255)
    Elsif Scond then
       DRAWARROWDOWN(barindex,high+offset) coloured(255,0,0,255)
    Endif
    RETURN
    #142209 quote
    fabio_effe
    Participant
    New

    Gentilissimo.

    Una domanda per cortesia: vedo che le frecce vengono poste molto distanti dalle candele sul grafico.

    Ci sarebbe un modo per avvicinarle in prossimità del prezzo?

    Grazie

    #142212 quote
    robertogozzi
    Moderator
    Master

    Cambia il numero di pips alla riga 9.

    Ho messo 100 sul TF Daily col Dax.

    Per farlo variabile in modo automatico scrivi la riga 9 cosi:

    Offset = average[20,0](range) * 1.5
    #142215 quote
    fabio_effe
    Participant
    New

    Perfetto!

    Grazie mille

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

MACD con filtro su superamento massimo/minimo precedente


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
fabio_effe @fabio_effe Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by fabio_effe
5 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 08/20/2020
Status: Active
Attachments: No files
Logo Logo
Loading...