Cambio Colore del Trend di un’indicatore
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Cambio Colore del Trend di un’indicatore
- This topic has 14 replies, 2 voices, and was last updated 3 years ago by
robertogozzi.
-
-
12/27/2021 at 6:41 PM #183899
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
12/27/2021 at 6:51 PM #183903Ecco le righe che puoi usare:
123Verde = MagicTrend > MagicTrend[1]Rosso = MagicTrend < MagicTrend[1]Cambio = (Verde AND Rosso[1]) OR (Verde[1] AND Rosso)12/27/2021 at 7:53 PM #18390612/27/2021 at 9:50 PM #183908È perfetto, Cambio segnala se c’è stato una variazione di colore oppure no.
12/27/2021 at 10:37 PM #18390912/27/2021 at 11:00 PM #18391212/28/2021 at 12:15 AM #183919Fai una foto (screenshot) e allegalo con il pulsante “select file”.
Posta anche il codice che hai usato.
12/28/2021 at 12:59 AM #183921//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”
12/28/2021 at 9:30 AM #183932Non 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.
12/28/2021 at 3:38 PM #18402712/28/2021 at 3:57 PM #184032Ci sono alcuni errori nelle ultime righe e non funziona.
Fai un copia un incolla completo, oppure esporta il file ITF ed allegalo.12/28/2021 at 4:17 PM #184036eccolo come allegato.
a titolo informativo è lo stesso riportato nel link:
https://www.prorealcode.com/prorealtime-indicators/magic-trend-indicator/
12/30/2021 at 2:48 PM #18415812/30/2021 at 8:05 PM #184170Ho provato, ma non sono ancora riuscito ad risolvere il problema.
Abbi ancora un po’ di pazienza.
01/02/2022 at 10:48 AM #184309Ecco fatto:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667ONCE cciP = 20ONCE atrP = 14ONCE atrM = 1ONCE smaP = 5ONCE 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 = 0ONCE Verde = 0ONCE Rosso = 0//IF BarIndex > max(cciP,atrP) THENlastCCI = thisCCIthisCCI = CCI[cciP](typicalPrice)myATR = AverageTrueRange[atrP](close)//temp1 = myATR * atrMupT = low - temp1downT = high + temp1//temp2 = Average[smaP,0](myATR) * atrMbuffDN = high + temp2buffUP = low - temp2//IF (thisCCI >= 0) AND (lastCCI < 0) THENbuffUP = buffDN[1]ENDIFIF (thisCCI <= 0) AND (lastCCI > 0) THENbuffDN = buffUP[1]ENDIFIF (thisCCI >= 0) THENIF (buffUP < buffUP[1]) THENbuffUP = buffUP[1]ENDIFELSIF (thisCCI <= 0) THENIF (buffDN > buffDN[1]) THENbuffDN = buffDN[1]ENDIFENDIFIF thisCCI >= 0 THENMagicTrend = buffUPELSIF thisCCI <= 0 THENMagicTrend = buffDNENDIF//Verde = MagicTrend > MagicTrend[1]Rosso = MagicTrend < MagicTrend[1]Neutro = MagicTrend = MagicTrend[1]IF Neutro THENVerde = Verde[1]Rosso = Rosso[1]ENDIFCambio = (Rosso AND Verde[1]) OR (Rosso[1] AND Verde)//ELSEthisCCI = 0lastCCI = 0myATR = 0buffUP = 0buffDN = 0buffDN = 0buffUP = 0MagicTrend = 0ENDIFRETURN Cambio AS "Cambio" -
AuthorPosts
Find exclusive trading pro-tools on