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

Re: [amibroker] Re: Help with formula- again...



PureBytes Links

Trading Reference Links

The PREV constant allows you to create self-referencing formulas.  A self
referencing formula is one that is able to reference the "previous" period's
value of itself.
For example, the following is an example of a self referencing formula:
((H+L+C)/3) + PREV
This simple formula divides the high, low, and closing prices by 3 and then
adds this value to yesterday's value of the ((H+L+C)/3).
The calculation of the popular indicator On Balance Volume illustrates the
use of the PREV function.

(if(c>ref(c,-1),1,-1)*volume)+PREV
Although On Balance Volume can be calculated without the use of the PREV
function, an exponential moving average cannot (other than using the mov()
function).  The following formula shows how a 18% exponential moving average
(approximately 10-periods) is calculated using the PREV function.
(close*0.18)+(PREV*0.82)

If you are using the PREV variable in a location within a custom indicator
that will cause the calculation to be very slow.  You should normally try to
avoid using the PREV variable as a DATA ARRAY when there is also a PERIODS
specified (e.g., mov(prev, 20, s), hhv(prev, 30), etc.).  Although use of
the PREV function in this way is allowable, it will take a long time to
calculate, particularly if a lot of data is loaded in the chart.
Regards

Don McKay

----- Original Message -----
From: "gillesdeprez" <gillesdeprez@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, September 06, 2003 4:36 PM
Subject: [amibroker] Re: Help with formula- again...


> Ok, but then what do I write instead of PREV? That's my main problem,
> I have no idear what PREV refers to...
>
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "mrdavis9" <mrdavis9@xxxx> wrote:
> > Should you have iif in the fifth line instead of if??  Ron D
> >   ----- Original Message -----
> >   From: gillesdeprez
> >   To: amibroker@xxxxxxxxxxxxxxx
> >   Sent: Saturday, September 06, 2003 12:42 AM
> >   Subject: [amibroker] Help with formula- again...
> >
> >
> >   Hello,
> >   After fighting for hours, I give up after the fifth line, before
> I
> >   jump trhu the window, screaming! I know I jump often- I live on
> the
> >   ground level.
> >   If one of you knows MS and is kind enough to give me a hand...
> >   "Recursive moving trend average"
> >   Lb:=Input("Look-Back Period?",3,100,21);
> >   Ty:=Input("1=C 2=H 3=L 4= Median Price",1,4,1);
> >   Tv:=If(Ty=1,C,If(Ty=2,H,If(Ty=3,L,MP())));
> >   Alpha:=2/(LB+1);
> >   Bot:=(1-Alpha)*(If(Cum(1)<Lb,Tv,PREV))+Tv;
> >   RMTA:=(1-Alpha)*(If(Cum(1)<Lb,Tv,PREV))+
> >   (Alpha*(Tv+Bot-Ref(Bot,-1)));
> >   RMTA
> >
> >   TIA!
> >   Gilles
> >
> >
> >
> >   Send BUG REPORTS to bugs@xxxx
> >   Send SUGGESTIONS to suggest@xxxx
> >   -----------------------------------------
> >   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> >   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> >   --------------------------------------------
> >   Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> >
> >   Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

>
>
>


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/