[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Functions KMA, MLR



PureBytes Links

Trading Reference Links

>
> Subject: Functions
> Date: Wed, 21 Jan 2004 22:32:20 -0500
> From: JRhodes <jrrhodes@xxxxxxxxxxx>
> To: omega-list@xxxxxxxxxx
>
> I earlier asked about the AMA  (Adaptive Moving Average) and the MLR
> (Moving Linear Regression).  I have since found that the AMA is a function
> in TS 7.2.  Functions are Read-only.  How can I move a function into the
> indicator category and apply it?
>
> John
>

Is the 7.2 AMA actually Kaufman ?  I ran 7.2 for one day, didn't notice it.

Here is an old post from the list by Don Roos with the code for the KMA.
This version has two added variables, FASTEND and SLOWEND.
These modify the action of the KMA.  To see the raw KMA set them to zero.
Also, they could be made inputs.  For some reason I never tried that.

==========================================================
Date: Fri, 12 Mar 1999 12:08:07 -0600
From: Don Roos <roos@xxxxxxxxxxxxxxx>
To: "code-list@xxxxxxxxxxxxx" <code-list@xxxxxxxxxxxxx>
Subject: Kaufman Adap MAs

By changing the constant in "smooth=@
power(efratio*(fastend-slowend)+slowend,2)" from 2 to 1 and 3, one can
create a fast, regular and slow kama.  They crossover much faster than
regular emas and follow the price trends very closely.  I have been
using a period of 10 for all 3 and applying the 3 kamas to the tick
also, looking for a reaction back across the fast kama for price and
tick (after a crossover of the fast and regular kama on both the price
and tick indicates a trend change). When the price and tick start moving
with the trend again, pull the trigger.  Avoiding triggering unless the
sto is overcooked is a good idea, as well as using in conjunction with
fib timelines helping to eliminate false signals in a congestion zone.
If anyone wants to look at programing these parameters (without the
timelines which are chosen from swings somewhat subjectively), one could
test this method of discretionary scalping.  Using an exit from a
crossover of the price with one of the kamas could be used.

Good trading,

Don
===============  KMA Function =================

Inputs:  Price(NumericSeries), period(Numeric);
Vars:  noise(0), signal(0), diff(0), efratio(0), smooth(1), fastend(.666),
slowend(.0645), AM(0);

{ Calculate efficiency ratio }

diff = @AbsValue(Price - Price[1]);
if (currentbar <= period)
then AM = Price
else begin
    signal = @AbsValue(Price - Price[period]);
    noise = @Summation(diff, period);
    if (noise = 0)
      then efratio = efratio[1]
      else efratio = signal / noise;
    smooth = @power(efratio * (fastend-slowend) + slowend, 2);

    AM = AM[1] + smooth * (Price - AM[1]);
end;

_KaufMA = AM;

=================  Calling Indicator ===================
Inputs:  Period(100) ;

Plot1 (_KaufMA(c,period),"KMA");
==================================================

**************************************************************
Here is the version I use.  I modified it to accept a 'Days' length as the input.
It requires intraday data.   It automatically adjusts the number of bars for the
bar interval. Therefore if you change from 10 minute bars to 5 minute, the
indicator provides the same curve.  You don't have to use a Bar length input.
The Days input can be fractional - 0.2 days is about 1.5 hours.

================  Indicator  - KMA_ID =====================

Inputs:   LenDays(1), Price((c+h+l)/3);
Vars:  noise(0), signal(0), diff(0), efratio(0), smooth(1), fastend(.666),
slowend(.0645), AM(0), period(0);

{ Calculate efficiency ratio }

period = LenDays * (390 / BarInterval);  { calculate # of bars for the days }

diff = @AbsValue(Price - Price[1]);

if (currentbar <= period)
then AM = Price
else begin
    signal = @AbsValue(Price - Price[period]);
    noise = @Summation(diff, period);
 if (noise = 0)
      then efratio = efratio[1]
      else efratio = signal / noise;
    smooth = @power(efratio * (fastend-slowend) + slowend, 2);
    AM = AM[1] + smooth * (Price - AM[1]);
end;

Plot1 (round(AM,1),"KMA") ;
========================================================


donc