| Drawing Functions
| drawicon |
drawicon(cond, pos, type):
cond: a single number or an array of numbers;
pos: a single number or an array of numbers;
type: integer number from 0-12.
draw icons at the position pos if cond != 0.
type has the following meaning:
0: happy face;
1: happy face;
2: sad face;
3: face;
4: blue up arrow;
5: red down arrow;
6: blue flag;
7: red flag;
8: blue up triangle:
9: red down trigangle;
10: blue boll;
11: red boll;
12: green boll;
|
drawicon(date=1051011,1.01*h,0);
drawicon(date=1051012,1.01*h,1);
drawicon(date=1051013,1.01*h,2);
drawicon(date=1051014,1.01*h,3);
drawicon(date=1051017,1.01*h,4);
drawicon(date=1051018,1.01*h,5);
drawicon(date=1051019,1.01*h,6);
drawicon(date=1051020,1.01*h,7);
drawicon(date=1051021,1.01*h,8);
drawicon(date=1051024,1.01*h,9);
drawicon(date=1051025,1.01*h,10);
drawicon(date=1051026,1.01*h,11);
drawicon(date=1051027,1.01*h,12);
|
k := "kdj.k"(20, 3, 3);
d := "kdj.d"(20, 3, 3);
j := "kdj.j"(20, 3, 3);
buy := d < 20 && cross(k, d);
sell := d > 80 && cross(d, k);
drawicon(buy, 0.99*low, 1);
drawicon(sell, 0.99*low, 2);
|
 |
 |
drawline |
drawline(cond1, pos1, cond2, pos2, expand):
cond1: a single number or an array of numbers;
pos1: a single number or an array of numbers;
cond2: a single number or an array of numbers;
pos2: a single number or an array of numbers;
expand: integer number 0 or 1.
draw a line segment starting from position pos1 where cond1 !=0 and
terminating at postion pos2 where cond2 != 0; if expand = 1, expand the
line segment from pos2 to the chart bord.
|
n:=80; m:=40;
a:=backset(islastbar,hhvbars(h,n)+1);
b:=count(a,2)=1;
drawicon(b, h, 10), align2;
a2:=backset(islastbar,hhvbars(h,m)+1);
b2:=count(a2,2)=1;
drawicon(b2, h, 10), align2;
drawline(b, h, b2, h, 1);
|
# draw horizontal lines without using drawline
n:=40;
a:=backset(islastbar,hhvbars(h,n)+1);
b:=count(a,2)=1;
drawicon(b, h, 10), align2;
d:= barslast(b);
polyline(count(a,2) > 0, ref(h,d));
a2:=backset(islastbar,llvbars(l,n)+1);
b2:=count(a2,2)=1;
drawicon(b2, l, 11), align1;
d2:= barslast(b2);
polyline(count(a2,2) > 0, ref(l,d2));
|
 |
 |
| polyline |
polyline(cond, pos):
cond: a single number or an array of numbers;
pos: a single number or an array of numbers.
draw connected line segments using pos as vertices where cond != 0.
|
cond:=backset(ref(high,2)=hhv(high,5),3);
drawicon(cond>ref(cond,1),h*1.01,10);
polyline(cond>ref(cond,1),h),colorblue,linestyle1;
|
ma(close,5),linethick2,colorgreen;
polyline(1,ma(ma(close,5),2)), colorgreen;
polyline(1,ma(ma(close,5),4)), colorgreen;
polyline(1,ma(ma(close,5),6)), colorgreen;
polyline(1,ma(ma(close,5),8)), colorgreen;
polyline(1,ma(ma(close,5),10)), colorgreen;
polyline(1,ma(ma(close,5),12)), colorgreen;
polyline(1,ma(ma(close,5),14)), colorgreen;
polyline(1,ma(ma(close,5),16)), colorgreen;
polyline(1,ma(ma(close,5),18)), colorgreen;
polyline(1,ma(ma(close,5),20)), colorgreen;
polyline(1,ma(ma(close,5),22)), colorgreen;
polyline(1,ma(ma(close,5),24)), colorgreen;
polyline(1,ma(ma(close,5),26)), colorgreen;
polyline(1,ma(ma(close,5),28)), colorgreen;
polyline(1,ma(ma(close,5),30)), colorgreen;
polyline(1,ma(ma(close,5),32)), colorgreen;
|
 |
 |
| stickline |
stickline(cond, pos1, pos2, width, empty):
cond: a single number or an array of numbers;
pos1: a single number or an array of numbers;
pos2: a single number or an array of numbers;
width: integer number 0 or 1;
empty: integer number 0 or 1.
draw line sticks or rectangles between postions pos1 and pos2 when cond != 0;
if width = 0, draw line sticks; otherwise draw rectangles;
if width = 1 and empty = 0, fill rectangles with color;
if width = 1 and empty = 1, rectangles are not filled;
|
stickline(isequal and c>=ref(c,1),c,c,1,1), colorblue;
stickline(isequal and c<ref(c,1),c,c,1,1), colorgreen;
stickline(isup,h,c,0,0), colorblue;
stickline(isup,l,o,0,0), colorblue;
stickline(isup,c,o,2,1), colorblue;
stickline(isdown,h,o,0,0), colorgreen;
stickline(isdown,l,c,0,0), colorgreen;
stickline(isdown,o,c,2,0), colorgreen;
|
a:=c-o;
b:=c>o;
stickline(b,o,o+a/4,2,0),colorff99ff;
stickline(b,o+a/4,o+a*2/4,2,0),colorff00ff;
stickline(b,o+a*2/4,o+a*3/4,2,0),color9900ff;
stickline(b,o+a*3/4,o+a,2,0),color0000ff;
|
 |
 |
fillrgn
|
fillrgn(pos1, pos2):
fillrgn(cond, pos1, pos2):
cond: a single number or an array of numbers;
pos1: a single number or an array of numbers;
pos2: a single number or an array of numbers.
fillrgn(pos1, pos2): fill the region formed by pos1 and pos2 with color when pos1 is above pos2;
fillrgn(cond, pos1, pos2): fill the region formed by pos1 and pos2 with color when cond != 0.
|
a:=ma(c,5);
b:=ma(c,10);
fillrgn(1,h*1.01,h*1.02),colorgreen, transparency3;
fillrgn(a>=b,a,b),colorblue, transparency3;
fillrgn(a<b,a,b),colormagenta, transparency3;
fillrgn(1,l*0.99,l*0.98),colorff99cc, transparency3;
|
a:=ma(c,5);
b:=ma(c,10);
fillrgn(a, b), colorblue, transparency3;
ma5: a, colorblue;
ma10: b, colorred;
|
 |
 |
| partline |
partline(cond, pos);
cond: a single number or an array of numbers;
pos: a single number or an array of numbers.
draw line segments using pos as its endpoints when cond != 0
|
rsv:=(close-llv(low,9))/(hhv(high,9)-llv(low,9))*100;
k:sma(rsv,3,1);
d:sma(k,6,1), colorgreen;
partline(k>d,k),colorred,linethick2;
|
ma5:ma(c,5),colorred;
partline(ma5<ref(ma5,1),ma5),colorgreen;
ma10:ma(c,10),colorred;
partline(ma10<ref(ma10,1),ma10),colorgreen;
ma20:ma(c,20),colorred;
partline(ma20<ref(ma20,1),ma20),colorgreen;
|
|
|
| vertline |
vertline(cond):
cond: a single number or an array of numbers.
draw vertical lines from the chart bottom to its top when cond != 0.
|
a:=month>ref(month,1);
vertline(a),color80ff40,linestyle1;
|
ma(c, 20);
vertline(c > ma(c, 20)), colorblue;
|
 |
 |
| drawnumber |
drawnumber(cond, pos, n):
drawnumber(cond, pos, n, precision):
cond: a single number or an array of numbers;
pos: a single number or an array of numbers;
n: a single number or an array of numbers to be displayed;
precision: integer number from 0-3 representing digits number after decimal point.
display the number at pos using the specified precision when cond != 0.
if precision is missing, the default precision is used.
|
a := peak(3, 1);
b := trough(3, 1);
drawnumber(a != ref(a, 1), h, h, 1), align2;
drawnumber(b != ref(b, 1), l, l, 1), align1;
|
n := 20;
va :=if(h > l, (2*c-(h+l))/(h-l)*v, 0);
mfi: sum(va,n)/sum(v,n);
drawnumber(every(c > ref(c, 1), 3) & c > ma(c, 30), mfi, mfi, 2);
|
 |
 |
| drawtext |
drawtext(cond, pos, "text"):
cond: a single number or an array of numbers;
pos: a single number or an array of numbers;
text: a text string surrounded by double quotes "".
display text at pos when cond != 0.
|
a := peak(3, 1);
b := trough(3, 1);
drawtext(a != ref(a, 1), h, "peak"), align2;
drawtext(b != ref(b, 1), l, "trough"), align1;
|
drawtext(ref(l, 1) = llv(l, 40) & c/o>1.01,l,"rally started?"),align1,colorgreen;
|
 |
 |
|