| Indicator Functions
| zig |
zig(n):
zig(x, n):
n: a single percentage number;
x: an array of numbers.
return results representing zigzag lines which reverse when the change is more than n%.
Unless x is provided, high and low prices are used.
|
zig(15), linethick2;
zig(low, 15);
|
ma: ma(close, 5);
zig(ma, 5);
|
 |
 |
|
peak
peakbars
|
peak(n, m):
peak(x, n, m);
peakbars(n, m):
peakbars(x, n, m):
n: a single percentage number;
m: integer number;
x: an array of numbers.
peak(n,m): return the mth peak value of zig(n);
peak(x, n,m): return the mth peak value of zig(x, n);
peakbars(n, m): return the period number between the current period and the mth peak of zig(n).
peakbars(x, n, m): return the period number between the current period and the mth peak of zig(x, n).
Unless x is provided, high and low prices are used.
|
polyline(1,zig(h,5)), colorlightbrown;
h1:peak(high,5,1), colorgreen;
h2:peak(high,5,2), colorred;
h1:peakbars(high,5,1), colorgreen;
h2:peakbars(high,5,2), colorred;
|
n := 10;
zig(n), colorlightbrown;
a1:=backset(islastbar,peakbars(n,1)+1);
a2:=a1>ref(a1,1);
b1:=backset(islastbar,peakbars(n,2)+1);
b2:=b1>ref(b1,1);
d1:=backset(islastbar,peakbars(n,3)+1);
d2:=d1>ref(d1,1);
drawline(d2,h,b2,h,1);
drawline(b2,h,a2,h,1);
|
 |
 |
trough
troughbars
|
trough(n, m):
trough(x, n, m);
troughbars(n, m):
troughbars(x, n, m):
n: a single percentage number;
m: integer number;
x: an array of numbers.
trough(n, m): return the mth trough value of zig(n);
trough(x, n, m): return the mth trough value of zig(x, n);
troughbars(n, m): return the period number between the current period and the mth trough of zig(n).
troughbars(x, n, m): return the period number between the current period and the mth trough of zig(x, n).
Unless x is provided, high and low prices are used in these functions.
|
polyline(1,zig(low,5)), colorlightbrown;
h1:trough(low,5,1), colorgreen;
h2:trough(low,5,2), colorred;
h1:troughbars(low,5,1), colorgreen;
h2:troughbars(low,5,2), colorred;
|
n := 10;
zig(n), colorlightbrown;
a1:=backset(islastbar,troughbars(n,1)+1);
a2:=a1>ref(a1,1);
b1:=backset(islastbar,troughbars(n,2)+1);
b2:=b1>ref(b1,1);
d1:=backset(islastbar,troughbars(n,3)+1);
d2:=d1>ref(d1,1);
drawline(d2,l,b2,l,1);
drawline(b2,l,a2,l,1);
|
 |
 |
peaktrough
peaktroughbars
|
peaktrough(n, m):
peaktrough(x, n, m);
peaktroughbars(n, m):
peaktroughbars(x, n, m):
n: a single percentage number;
m: integer number;
x: an array of numbers.
peaktrough(n, m): return the mth peak or trough value of zig(n);
peaktrough(x, n, m): return the mth peak or trough value of zig(x, n);
peaktroughbars(n, m): return the period number between the current
period and the mth peak or trough of zig(n).
peaktroughbars(x, n, m): return the period number between the current
period and the mth peak or trough of zig(x, n).
Unless x is provided, high and low prices are used in these functions.
|
polyline(1,zig(10)), colorlightbrown;
h1:peaktrough(10,1), colorgreen;
h1:peaktroughbars(10,1), colorgreen;
|
polyline(1,zig(10)), colorlightbrown;
h2:peaktrough(10,2), colorred;
h2:peaktroughbars(10,2), colorred;
|
 |
 |
sar
sarturn
|
sar(n, s, m): sarturn(n, s, m):
n: period number;
s: a single number representing step;
m: a single number representing step limit, s < m;
sar(n, s, m): return trailing stop positions which follow a prevailing trend.
sarturn(n, s, m): return
1, when sar turns to long:
-1, when sar turns to short;
0, otherwise.
|
s := sar(10, 2, 20);
st := sarturn(10, 2, 20);
s, pointdot, linethick4;
drawicon(st = 1, s, 10), align1;
drawicon(st = -1, s, 11), align2;
|
# color sar
csar:sar(3,2,20),linethick0;
drawicon(csar>=h,csar,11);
drawicon(csar<=l,csar,10);
cond1:=backset(sarturn(3,2,20)<>0,2);
cond2:=ref(cond1,1)<cond1;
drawicon(cond2,csar,12); |
|
 |
 |
cost
winner
|
cost(n):
winner(x):
n: a single percentage number, for example 50, 80 etc.
x: a single number or an array of numbers.
cost(n): return the cost price under which n percent of the shares float are winning.
winner(x): return a number from 0-1 indicating indicating the percentage of the
indicating the percentage of shares displayed in the CYQ chart that are
held below the price x.
|
average_cost:cost(50);
aa:=sumbars(vol,capital);
average_price:sum(c*v,aa)/sum(v,aa);
|
hs:vol/capital*100;
avol:abs(winner(close)-winner(open))*100, volstick;
control:=avol>=10 and ma(hs,5)<=3 or (avol/hs)>9;
drawicon(control,avol,10);
20, pointdot;
|
 |
 |
|