Bonjour @Iván, bon j’ai mis le temps à comprendre que le code que tu as écrit décliné plusieurs types de configurations de “Divergences”. Ma première lecture était donc mauvaise car ton code fonctionne parfaitement!
A partir de là, je l’ai simplifié en retirant le bloc entre les lignes 84 à 87, car c’est la partie Price + CumulativeDelta qui m’intéresse le plus! Dans un premier temps les “Epuisements” et dans un deuxième temps ce sera les “Absorptions”.
Donc, au doigt mouillé, j’ai repris la partie de ton code pour matérialiser les “Epuisements Haussiers”, que j’ai tenté de remodeler pour faire ressortir les “Epuisements Baissiers”. Résultat, j’ai tout cassé, plus rien ne fonctionne, plus rien ne s’affiche !!!
Aurais-tu une idée ? Merci
//"Absorption-Epuisement PriceCumDelta" Cycle via MACD
//--------------------------------------------------------//
//--------------------------------------------------------//
//"Cumulative Delta" (by Nicolas/ProRealcode)
//--------------------------------------------------------//
//U1
if(close>=open and (close-open+2*(high-close)+2*(open-low)))>0 then
U1= volume*(high-low)/(close-open+2*(high-close)+2*(open-low))
else
U1=0.0
endif
//D1
if(close<open and (open-close+2*(high-open)+2*(close-low)))>0 then
D1 = volume*(high-low)/(open-close+2*(high-open)+2*(close-low))
else
D1=0.0
endif
//--------------------------------------------------------//
//Delta
if(close>=open) then
Delta= U1
else
Delta= -D1
endif
//--------------------------------------------------------//
if barindex>1 then
cumDelta=(cumDelta[1])+Delta
if close>=open then
hi= cumDelta
r=255
g=255
b=255
else
hi =cumDelta[1]
endif
if close<=open then
lo= cumDelta
r=255
g=0
b=0
else
lo=cumDelta[1]
endif
drawcandle(cumDelta[1], hi, lo, cumDelta) coloured(r,g,b)
endif
//--------------------------------------------------------//
//-----MACD-----------------------------------------------//
fastema=average[12,1](close)
slowema=average[26,1](close)
mymacd=fastema-slowema
signal=average[9,1](mymacd)
histo=mymacd-signal
//--------------------------------------------------------//
if histo crosses under 0 then
$priceLow[n+1]=low
$histoLow[n+1]=histo
$cumdeltaLow[n+1]=cumdelta
$barprice[n+1]=barindex
$barhisto[n+1]=barindex
$bardelta[n+1]=barindex
n=n+1
elsif histo < 0 then
if low < $pricelow[n] then
$pricelow[n]=low
$barprice[n]=barindex
endif
if histo < $histolow[n] then
$histoLow[n]=histo
$barhisto[n]=barindex
endif
if cumdelta < $cumdeltalow[n] then
$cumdeltaLow[n]=cumdelta
$bardelta[n]=barindex
endif
endif
//--------------------------------------------------------//
if histo crosses over 0 then
$priceHigh[n+1]=high
$histoHigh[n+1]=histo
$cumdeltaHigh[n+1]=cumdelta
$barprice[n+1]=barindex
$barhisto[n+1]=barindex
$bardelta[n+1]=barindex
n=n+1
elsif histo > 0 then
if high < $pricehigh[n] then
$pricehigh[n]=high
$barprice[n]=barindex
endif
if histo < $histohigh[n] then
$histoHigh[n]=histo
$barhisto[n]=barindex
endif
if cumdelta < $cumdeltahigh[n] then
$cumdeltahigh[n]=cumdelta
$bardelta[n]=barindex
endif
endif
//--------------------------------------------------------//
if n>1 then
//----- Epuisement Up-------------------------------------------------//
divPriceCumdeltaEU = $cumdeltalow[n]>$cumdeltalow[n-1] and $pricelow[n]<$pricelow[n-1]
//-----Divergence CumDelta & Price------------------------------------//
if histo crosses over 0 and divPriceCumdeltaEU then
drawarrowup(barindex,$cumdeltalow[n])coloured("lightgreen")
drawsegment($bardelta[n-1],$cumdeltaLow[n-1],$bardelta[n],$cumdeltaLow[n])coloured("lightgreen")
//-----Divergence Histogram-Price---------------------------------//
elsif histo crosses over 0 and divPriceCumdeltaEU then
drawarrowup(barindex,$cumdeltalow[n])coloured("yellow")
drawsegment($bardelta[n-1],$cumdeltaLow[n-1],$bardelta[n],$cumdeltaLow[n])coloured("yellow")
endif
endif
//--------------------------------------------------------//
if n>1 then
//----- Epuisement Down------------------------------------------------//
divPriceCumdeltaED = $cumdeltahigh[n]<$cumdeltahigh[n-1] and $pricehigh[n]>$pricehigh[n-1]
//-----Divergence CumDelta & Price------------------------------------//
if histo crosses under 0 and divPriceCumdeltaED then
drawarrowdown(barindex,$cumdeltahigh[n])coloured("lightgreen")
drawsegment($bardelta[n-1],$cumdeltahigh[n-1],$bardelta[n],$cumdeltahigh[n])coloured("red")
//-----Divergence Histogram-Price---------------------------------//
elsif histo crosses under 0 and divPriceCumdeltaED then
drawarrowdown(barindex,$cumdeltahigh[n])coloured("yellow")
drawsegment($bardelta[n-1],$cumdeltahigh[n-1],$bardelta[n],$cumdeltahigh[n])coloured("yellow")
endif
endif
//--------------------------------------------------------//
Return
//--------------------------------------------------------//