Cambio Colore del Trend di un’indicatore

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #183899 quote
    raffa58raffa58
    Participant
    Average

    Buongiorno Roberto,

    può aiutarmi a codificare all’interno di un indicatore come ad esempio  Magic Trend Indicator il cambio del trend da verde a rosso.

    Ho seguito le istruzione che riporto per facilitare la lettura  ma il codice risulta in errore , sicuramente qualcosa mi sfugge , può aiutarmi ?

    grazie in anticipo

    If MagicTrend <> MagicTrend[1] then it’s Green or Red

    Saluti

    Raffaele

    #183903 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ecco le righe che puoi usare:

    Verde  = MagicTrend > MagicTrend[1] 
    Rosso  = MagicTrend < MagicTrend[1] 
    Cambio = (Verde AND Rosso[1]) OR (Verde[1] AND Rosso)
    #183906 quote
    raffa58raffa58
    Participant
    Average

    Grazie. Il Return come andrebbe codificato ?

    Così scritto (è probabile che non sia corretto), non evidenza il cambio del trend

    RETURN Cambio

    grazie

    Raffaele

    #183908 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    È perfetto, Cambio segnala se c’è stato una variazione di colore oppure no.

    #183909 quote
    raffa58raffa58
    Participant
    Average

    allego il file  per condividere il risultato per capire se è corretto che non ci sia il cambio colore

    #183912 quote
    raffa58raffa58
    Participant
    Average

    Salve Roberto, ho provato a caricare il grafico con estensione .jpg;.tif;.pdf  con scarso successo.  Esiste una regola per postare il grafico che vorrei condividere ?

    grazie

    #183919 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Fai una foto (screenshot) e allegalo con il pulsante “select file”.

    Posta anche il codice che hai usato.

    #183921 quote
    raffa58raffa58
    Participant
    Average

    //cciP = 20
    //atrP = 14
    //atrM = 1
    //smaP = 5
    cciP = max(1,min(999,cciP))
    atrP = max(1,min(999,atrP))
    atrM = max(0.0000001,min(999,atrM))
    smaP = max(1,min(999,smaP))
    //
    IF BarIndex > max(cciP,atrP) THEN
    lastCCI = thisCCI
    thisCCI = CCI[cciP](typicalPrice)
    myATR = AverageTrueRange[atrP](close)
    //
    temp1 = myATR * atrM
    upT = low – temp1
    downT = high + temp1
    //
    temp2 = Average[smaP,0](myATR) * atrM
    buffDN = high + temp2
    buffUP = low – temp2
    //
    IF (thisCCI >= 0) AND (lastCCI < 0) THEN
    buffUP = buffDN[1]
    ENDIF
    IF (thisCCI <= 0) AND (lastCCI > 0) THEN
    buffDN = buffUP[1]
    ENDIF
    IF (thisCCI >= 0) THEN
    IF (buffUP < buffUP[1]) THEN
    buffUP = buffUP[1]
    ENDIF
    ELSIF (thisCCI <= 0) THEN IF (buffDN > buffDN[1]) THEN
    buffDN = buffDN[1]
    ENDIF
    ENDIF
    IF thisCCI >= 0 THEN
    MagicTrend = buffUP
    ELSIF thisCCI <= 0 THEN MagicTrend = buffDN ENDIF ELSE thisCCI = 0 lastCCI = 0 myATR = 0 buffUP = 0 buffDN = 0 buffDN = 0 buffUP = 0 MagicTrend = 0 ENDIF Verde = MagicTrend > MagicTrend[1]
    Rosso = MagicTrend < MagicTrend[1]
    Cambio = (Verde AND Rosso[1]) OR (Verde[1] AND Rosso)

    RETURN Cambio AS “MagicTrend”

    Immagine-2021-12-28-004139.png Immagine-2021-12-28-004139.png
    #183932 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Non lo vedi perché il valore CAMBIO può essere solo 0 oppure 1, quindi è lontano dal prezzo, se scendi col mouse finoi a al prezzo 0 lo vedrai.

    Mettilo sotto il grafico, poi settalo come linea o come istogramma, tramite le proprietà.

    Comunque quello che hai postato non mi pare sia lo stesso che è sul grafico, perché questo NON ti fa vedere il Magic Trend, ma solo il cambio, mentre sul grafico c’è la linea nera dell’indicatore vero e proprio.

    #184027 quote
    raffa58raffa58
    Participant
    Average

    Salve Roberto non mi è chiaro su cosa fare, comunque provo a postare il grafico in base a quanto ho capito .

    Immagine-2021-12-28-153350.png Immagine-2021-12-28-153350.png
    #184032 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ci sono alcuni errori nelle ultime righe e non funziona.
    Fai un copia un incolla completo, oppure esporta il file ITF ed allegalo.

    x-10.jpg x-10.jpg
    #184036 quote
    raffa58raffa58
    Participant
    Average

    eccolo come allegato.

    a titolo informativo è lo stesso riportato nel link:

    Magic Trend Indicator

    Magic-Trend-custom.itf
    #184158 quote
    raffa58raffa58
    Participant
    Average

    Buongiorno Roberto, ha avuto modo di verificare dove ho sbagliato per cui l’indicatore non evidenzia i risultati aspettati.

    grazie in anticipo

    #184170 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ho provato, ma non sono ancora riuscito ad risolvere il problema.

    Abbi ancora un po’ di pazienza.

    #184309 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Ecco fatto:

    ONCE cciP = 20
    ONCE atrP = 14
    ONCE atrM = 1
    ONCE smaP = 5
    ONCE cciP = max(1,min(999,cciP))
    ONCE atrP = max(1,min(999,atrP))
    ONCE atrM = max(0.0000001,min(999,atrM))
    ONCE smaP = max(1,min(999,smaP))
    //
    ONCE Neutro = 0
    ONCE Verde  = 0
    ONCE Rosso  = 0
    //
    IF BarIndex > max(cciP,atrP) THEN
    lastCCI = thisCCI
    thisCCI = CCI[cciP](typicalPrice)
    myATR   = AverageTrueRange[atrP](close)
    //
    temp1   = myATR * atrM
    upT     = low  - temp1
    downT   = high + temp1
    //
    temp2   = Average[smaP,0](myATR) * atrM
    buffDN  = high + temp2
    buffUP  = low  - temp2
    //
    IF (thisCCI >= 0) AND (lastCCI  < 0) THEN
    buffUP = buffDN[1]
    ENDIF
    IF (thisCCI <= 0) AND (lastCCI  > 0) THEN
    buffDN = buffUP[1]
    ENDIF
    IF (thisCCI >= 0) THEN
    IF (buffUP < buffUP[1]) THEN
    buffUP = buffUP[1]
    ENDIF
    ELSIF (thisCCI <= 0) THEN
    IF (buffDN > buffDN[1]) THEN
    buffDN = buffDN[1]
    ENDIF
    ENDIF
    IF thisCCI >= 0 THEN
    MagicTrend = buffUP
    ELSIF thisCCI <= 0 THEN
    MagicTrend = buffDN
    ENDIF
    //
    Verde  = MagicTrend > MagicTrend[1]
    Rosso  = MagicTrend < MagicTrend[1]
    Neutro = MagicTrend = MagicTrend[1]
    IF Neutro THEN
    Verde = Verde[1]
    Rosso = Rosso[1]
    ENDIF
    Cambio     = (Rosso AND Verde[1]) OR (Rosso[1] AND Verde)
    //
    ELSE
    thisCCI    = 0
    lastCCI    = 0
    myATR      = 0
    buffUP     = 0
    buffDN     = 0
    buffDN     = 0
    buffUP     = 0
    MagicTrend = 0
    ENDIF
    RETURN Cambio AS "Cambio"
    CambioMagicTrend.itf
Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Cambio Colore del Trend di un’indicatore


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
raffa58 @raffa58 Participant
Summary

This topic contains 14 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
4 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 12/27/2021
Status: Active
Attachments: 5 files
ProRealCode ProRealCode
Loading...