Of course you could just write it like this as well

gkATR = Max( H-L, Max( abs(L-Ref(C,-1)), abs(H-Ref(C,-1)) ));

--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com


On 27/11/06, Ed Hoopes <[EMAIL PROTECTED]> wrote:

Thank you Graham for the tip.  However I got impatient and decided to
write it myself.  Since I wanted to be able to call it from various
places I made it a Function.

So as pennance for my sin of clogging the forum with spurious requests
, Here is the function.

function ATREH ( FO, FH, FL, FC, Pers )
{
        global ATRVal, HL, PCH, PCL, HiHi;
        HL = FH - FL ; PCH = abs(Ref(FC, -1) - FH) ;  PCL = abs(Ref(FC,
-1) -
FL) ;
        EMAPrc   = (FO + FH + FL + FC ) / 4 ;
        EMA50    = EMA(EMAPrc, 50 ) ;
        HLHigh   = IIf(HL > PCH AND HL >  PCL,  HL, -1 );
        PCHHigh  = IIf(PCH > HL AND PCH > PCL, PCH, -1 );
        PCLHigh  = IIf(PCL > HL AND PCL > PCH, PCL, -1 );
        HiHi     = IIf(HLHigh >= 0, HLHigh, IIf(PCHHigh >= 0, PCHHigh,
IIf(PCLHigh >= 0, PCLHigh, 0 )));
        ATRVal   = 100 * MA(HiHi, Pers) / EMA50 ;
}

Which can be called by

ATREH ( XLEOpen, XLEHigh, XLELow, XLEClose, ATRPers ) ;

the result (in percent) is the ATRVal, which is passed out as a global
variable.

Sorry,

Ed Hoopes aka ReefBreak



--- In [email protected], Graham <[EMAIL PROTECTED]> wrote:
>
> ATR is based on 3 price arrays C,H,L so a single array would not be
any use
> in the function
> Just use the aTR inside a setforiegn / restorepricearrays zone in
the AFL
>
>
> --
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com
>
> On 27/11/06, Ed Hoopes <[EMAIL PROTECTED]> wrote:
> >
> > I would like to use the ATR() function on a 'Foreign' stock  -  so I
> > can calculate the volatility of - say SPY, but use that ATR value in
> > calculating an indicator on some other security.
> >
> > For example, there are 2 forms of RSI - RSI(Pers) and RSIa(Array,
Pers).
> >
> > Does anyone have a similar ATR function - say ATR(Array, Pers) ?
> >
> > Thanks,
> >
> > ReefBreak
> >
> >
> >
> >
> >
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

Yahoo! Groups Links




Reply via email to