Bonsoir,
j’utilise cet indicateur ci-dessous :
// Original Script > @DonovanWall
// Adapted Version > @guikroth
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////
DefParam DrawOnLastBarOnly = true
xClose = (Open+High+Low+Close)/4
// Source
src = xclose
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
// per = defval=100, minval=1, "Sampling Period"
// Range Multiplier
// mult = defval=3.0, minval=0.1, "Range Multiplier"
PER = 100
MULT = 3
// Smooth Average Range
wper = per*2 -1
avrng = exponentialaverage[per](abs(src-src[1]))
smrng = mult * exponentialaverage[wper](avrng)
// Range Filter
rngfilt = src
If src > rngfilt[1] then
If rngfilt[1] > src-smrng then
rngfilt = rngfilt[1]
Else
rngfilt = src-smrng
endif
elsif rngfilt[1] < src+smrng then
rngfilt = rngfilt[1]
else
rngfilt = src+smrng
endif
filt = rngfilt
// Filter Direction
upward = 0
If filt > filt[1] then
upward = upward[1]+1
elsif filt < filt[1] then
upward = 0
else
upward = upward[1]
endif
downward = 0
If filt < filt[1] then
downward = downward[1]+1
elsif filt > filt[1] then
downward = 0
else
downward = downward[1]
endif
// Target Bands
hband = filt + smrng
lband = filt - smrng
//// Zone de couleurs : selon des conditions
////////////////////////////////////////////////////////////////////////////
mbTendance = (Average[3](filt) + filt)/2
if mbTendance > mbTendance[1] then
red=0
green=0
blue=255
elsif mbTendance < mbTendance[1] then
red=255
green=0
blue=0
endif
colorbetween(lband,hband,red,Green,Blue,88)
if islastbarupdate then
if close
DRAWSEGMENT(barindex, hband, barindex+5, hband)style(line,2) coloured(0,0,200)
endif
if close>lband then
DRAWSEGMENT(barindex, lband, barindex+5, lband)style(line,2) coloured(0,0,200)
endif
endif
Return filt as "Range Filter", hband as "High Target", lband as "Low Target", mbtendance as "tendance"
J’aimerai sortir d’une position longue ou courte lorsque la bande de couleur change de couleur (ex : je suis long et lorsque la bande est de couleur rouge, je sors de ma position longue. J’ai essayé avec la formule “mbTendance < mbTendance[1] ” mais cela ne donne pas les résultats escomptés.
Merci.
Bjr,
a priori, sans éplucher l’intégralité du code, si je ne dis pas de bêtise on doit pouvoir exprimer le changement de couleur de bande par red<>red[1], donc on doit pouvoir tester la sortie de position longue (sous proorder car longonmarket mot spécifique) avec ce if:
if longonmarket and red<>red[1] then
sell at market
endif
resp. pour sortie de short:
if shortonmarket and red<>red[1] then
exitshort at market
endif
Bonsoir,
merci pour la rapidité de la réponse.
je teste et vous reviens.
Philippe.