PureBytes Links
Trading Reference Links
|
Dear Anthony,
In your #3673, Question 2:
<FONT
size=2>p1=peak(h,10,1);v1=valuewhen(p1!=ref(p1,-1),cum(1),1);tr1=trough(l,10,1);v2=valuewhen(tr1!=ref(tr1,-1),cum(1),1);
From AmiBroker 3.65 User's Guide you can
see
PEAK (AFL 1.1)
SYNTAX
peak(ARRAY, change, n = 1)
RETURNS
ARRAY
FUNCTION
Gives the value of ARRAY n-th peak(s) ago. This
uses the Zig Zag function (see Zig Zag) to determine the peaks. n
=1 would return the value of the most recent peak. n =2 would
return the value of the 2nd most recent peak. Caveat: this function
is based on Zig-Zag indicator and may look into the future.
EXAMPLE
peak(close,5,1)
and
TROUGH (AFL 1.1)
SYNTAX
trough(ARRAY, change, n = 1)
RETURNS
ARRAY
FUNCTION
Gives the value of ARRAY n-th trough(s) ago.This
uses the Zig Zag function (see Zig Zag) to determine the troughs.
Caveat: this function is based on Zig-Zag indicator and may look
into the future.
EXAMPLE
trough(close,5,1)
Any array (close, high, low etc) may be used. I wanted the highest
point
so I used H for PEAK, I wanted the lowest point so I used L for
TROUGH
Any change may be used. I used 10. Changes may be different.
(For some bearish stocks the combination 10 for PEAK and 5 for TROUGH
worked fine.)
From
No
Symbol
Meaning
1
^
Exponentiation
2
-
Negation - Unary minus
3
*
Multiplication
4
/
Division
5
+
Addition
6
-
Subtraction
7
<
Less than
8
>
Greater than
9
<=
Less than or equal to
10
>=
Greater than or equal to
11
==
Equal to
12
!=
Not equal to
13
NOT
Logical "Not"
14
AND
Logical "And"
15
OR
Logical "Or"
16
=
Variable assignment operator
the No 12 is != and means "Not equal to".
But, I will not reproduce here the manual. It is better to read it.
In my opinion it is very well written. And with every new update
it becomes better. Someone is working for that purpose
And, please, do not confuse things. When we say opinion,
it is ONLY personal, you do not have to adopt or accept or
follow it.
AFL is a powerful tool and, for me, VERY friendly to the user.
Suppose it helps your Question 2 .
Dimitris Tsokakis
|