// MOYENNE ADAPTIVE BOITE DE DARVAS
// BOITES de DARVAS
//***Darvas Boxes Code by courtesy of Sohocool
if box=1 and (high>db100 or low<db0) then
box=0
flag=0
endif
if box=0 and flag=0 and low>low[3] and low[1]>low[3] and low[2]>low[3] then
th=low[3]
flag=1
endif
if flag=1 and box=0 and low<th then
flag=0
endif
if flag=1 and box=0 and high<high[3] and high[1]<high[3] and high[2]<high[3] then
db100=high[3]
db0=th
box=1
endif
once db100=undefined
once db0=undefined
temp=db100-db0
//db23=db0+0.236*temp
//db38=db0+0.382*temp
db50=db0+0.5*temp
//db62=db0+0.618*temp
//db78=db0+0.786*temp
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//KAMA Kaufman Adaptiv Moning Average …………PRT
ONCE ama = UNDEFINED
signal = ABS(MOMENTUM[p])
noise = SUMMATION[p](ABS(MOMENTUM[1]))
IF noise>0 THEN
er = signal / noise
ELSE
er=1
ENDIF
fastsc = 2 / (2+ 1)
slowsc = 2 / (30 + 1)
factor = SQUARE(er * (fastsc - slowsc) + slowsc)
IF BARINDEX = p THEN
ama = CLOSE
ELSIF BARINDEX > p THEN
ama = ama + factor * (CLOSE - ama)
ENDIF
// Variable : p = 30
////////////////////////////////////////////////////
Mabdd = ama * ( db50 )
Return MABDD as " MABDD "