This code is an oscillator, not an indicator to put on the price chart.
I am not very gifted but I know that 😉
It is below the price chart
Here is my chart
Only “Indicateur” appears
Try this version:
//variable p =période de la moyenne
//smooth1=période de lissage
//smooth2=période du signal
p = 20
smooth1 = 3
if barindex>p+smooth1 then
a=average[p](customclose)
r=round(p/2) +1
b= customclose - a[r]
b1=average[smooth1](b)
// parameters :
Period = 10
FastPeriod = 2
SlowPeriod = 30
Fastest = 2 / (FastPeriod + 1)
Slowest = 2 / (SlowPeriod + 1)
if barindex < Period+1 then
Kama=b1
else
Num = abs(b1-b1[Period])
Den = summation[Period](abs(b1-b1[1]))
ER = Num / Den
Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
KAMA = (Alpha * b1) + ((1 -Alpha)* Kama[1])
endif
endif
return b1 coloured by momentum[1](b1) AS "Indicateur",0 as "Zero", kama as "Signal"
////////////////////////FIN du code
Too strong Nicolas! It works well.
So he was just missing an “endif” ?
A big thank you anyway and have a nice evening
lines 8 and 31 were added. I embed the whole code in a condition to check there are sufficient bars to complete the calculation.
When I say it was missing an endif, I mean it was missing an initialization
I saw Nicolas, thank you again. Have a nice evening.
Hello
When I add the kama ( or the ama) code next to the macd ZL code, I have a error message, don t know why … Here is the code
//moyenne mobile adaptative
Period = 10
FastPeriod = 2
SlowPeriod = 30
Fastest = 2 / (FastPeriod + 1)
Slowest = 2 / (SlowPeriod + 1)
if barindex < Period+1 then
Kama=close
else
Num = abs(close-close[Period])
Den = summation[Period](abs(close-close[1]))
ER = Num / Den
Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest)
KAMA = (Alpha * Close) + ((1 -Alpha)* Kama[1])
endif
return kama
// MACD ZLag
// --- settings
short = 12
long = 26
signal = 9
EMAshort1 = exponentialaverage[short](close)
EMAshort2 = exponentialaverage[short](EMAshort1)
DifferenceShort = EMAshort1 - EMAshort2
ZeroLagShort = EMAshort1 + DifferenceShort
EMAlong1 = exponentialaverage[long](close)
EMAlong2 = exponentialaverage[long](EMAlong1)
DifferenceLong = EMAlong1 - EMAlong2
ZeroLagLong = EMAlong1 + DifferenceLong
ZeroLagMACD = ZeroLagShort - ZeroLagLong
signal1=ExponentialAverage[signal](ZEROLAGMACD)
signal2=ExponentialAverage[signal](signal1)
DIFFERENCE2=signal1-signal2
SignalMACD=signal1+DIFFERENCE2
Error message on the screen: ” erreur de syntaxe une des expressions suivantes serait plus adaptés que “short” probuilder.error.suggestion.EOF “\n” ”
An idea ? Many thanks in advance
Michel
Ok sorry I think I found my mistable reading it another time …
return kama was tooo much
Sorry !