PureBytes Links
Trading Reference Links
|
the below uses perry kaufman's ama to give you an example.
function name it adaptive.......................step 1
inputs:price(numericseries),period(numericsimple);
vars: noise(0),signal(0),dif(0),efratio(0),
smooth(1),fastend(.666),slowend(.0645),am(0);
{CALCULATE EFFICIENCY RATIO}
dif=@xxxxxxxx(price - price[1]);
if(currentbar <= period) then am =price;
if(currentbar > period)then begin
signal = @AbsValue(price - price[period]);
noise = @Summation(dif,period);
efratio = signal/noise;
smooth = @Power(efratio*(fastend - slowend) + slowend,2);
{ADAPTIVE MOVING AVERAGE}
am = am[1] + smooth*(price - am[1]);
Adaptive=am;
end;
function name it MACDAMA ...............step 2
Inputs:Price(NumericSeries),FastMA(NumericSimple),SlowMA(NumericSimple);
MACDAMA = Adaptive(Price,FastMA) - Adaptive(Price,SlowMA);
indicator name it whatever you want ................step 3
Input: FastMA(12),SlowMA(26),MacdMA(9);
VALUE1=(MACDAMA(Close,FastMA,SlowMA));
VALUE2=(XAverage(MACDAMA(Close,FastMA,SlowMA),MacdMA));
Plot3(VALUE1-VALUE2,"MADiff");
|