Hello:
I would like to know the syntax for drawing a line and a square on a chart. I tried a DRAWLINE command but it didn't seem to work. I was able to draw a square - but I don't fully understand all parameters for that function.
Could someone please let me know the Syntax and parameter list for the syntax ?
Also If someone had the syntax for all possible Draw Functions (and their parameters) - this would be most helpful.
Thanks,
Brian
How does one draw a line and square on a chart
Moderator: Chris White
-
- Posts: 212
- Joined: Mon Nov 29, 2010 9:21 pm
Re: How does one draw a line and square on a chart
Hi Brian,
A good resource to look at for examples of use of most functions is the actual code for all system indicators. You can find this code in the following location on your hard drive:
{Documents}\EdgeRater\ChartScripts\SystemIndicators.xml
In that file you can search for DRAWLINE and see that it has been used in the TMPL_GM_UAR_VALS script:
That script provides the values for the Gil Morales Undercut and Rally template and charts.
Here you can see that DRAWLINE takes 3 parameters:
1. Line data
2. Line start date
3. Line end date (-1 to draw to end of chart)
The DRAWLINE function draws the contents of LineData from StartDate to EndDate.
Shapes can be drawn using the DRAWSHAPE function:
eg from the VPA_Overlay script:
The parameters are:
1. Cond (array data containing 1s and 0s for when to draw the shape, 1= draw, 0 = don't draw)
2. y (array data containing Y value for the shape
3. relativePosition (which part of shape does pixelOffset apply to. 1 = top, -1 = bottom, 0 = center)
4. isAbove (1= draw shape above Y, 0 = below Y)
5. pixelOffset (offset for relativePosition)
6. ShapeName (see list below)
7. relWidth (width of shape)
8. colorOutline (color for shape outline)
9. colorFill (color for shape fill)
The list of possible shapeNames is:
Chris.
A good resource to look at for examples of use of most functions is the actual code for all system indicators. You can find this code in the following location on your hard drive:
{Documents}\EdgeRater\ChartScripts\SystemIndicators.xml
In that file you can search for DRAWLINE and see that it has been used in the TMPL_GM_UAR_VALS script:
Code: Select all
C1: REF(C, 1),norender;
Z1:= ZIG(L, 1);
Z5:= ZIG(L, 5);
Z10:= ZIG(L, 10);
EMA20: EMA(C, 20),colorgreen;
EMA65: EMA(C, 65),colorblack;
MA10: MA(C, 10),colormagenta;
MA50: MA(C, 50),colorblue;
MA200: MA(C, 200),colorred;
SLOPEMA50: MA50 - REF(MA50, 1),norender;
TURN1:= REF(Z1, 2) > REF(Z1, 1) & ( REF(Z1, 1) < Z1 );
TURN5:= REF(Z5, 2) > REF(Z5, 1) & ( REF(Z5, 1) < Z5 ), norender;
TURN10:= REF(Z10, 2) > REF(Z10, 1) & ( REF(Z10, 1) < Z10 ), norender;
VALLEY1:= REF(TURN1, -1);
VALLEY5:= REF(TURN5, -1);
VALLEY10:= REF(TURN10, -1);
LV1_1: VALUEWHEN(Z1, VALLEY1),norender;
LV5_1: VALUEWHEN(Z5, VALLEY5),norender;
LV10_1: VALUEWHEN(Z10, VALLEY10),norender;
STARTDATE:= DATELASTTRUE(C, VALLEY1);
DRAWLINE(LV1_1, STARTDATE, -1),colorred,pointdot;
STARTDATE:= DATELASTTRUE(C, VALLEY5);
DRAWLINE(LV5_1, STARTDATE, -1),colorblue,pointdot;
STARTDATE:= DATELASTTRUE(C, VALLEY10);
DRAWLINE(LV10_1, STARTDATE, -1),colorblack,pointdot;
Here you can see that DRAWLINE takes 3 parameters:
1. Line data
2. Line start date
3. Line end date (-1 to draw to end of chart)
The DRAWLINE function draws the contents of LineData from StartDate to EndDate.
Shapes can be drawn using the DRAWSHAPE function:
eg from the VPA_Overlay script:
Code: Select all
DRAWSHAPE(noDemandBar, H, -1, true, 10, 'SQUARE', 1,'BLACK','MAGENTA');
The parameters are:
1. Cond (array data containing 1s and 0s for when to draw the shape, 1= draw, 0 = don't draw)
2. y (array data containing Y value for the shape
3. relativePosition (which part of shape does pixelOffset apply to. 1 = top, -1 = bottom, 0 = center)
4. isAbove (1= draw shape above Y, 0 = below Y)
5. pixelOffset (offset for relativePosition)
6. ShapeName (see list below)
7. relWidth (width of shape)
8. colorOutline (color for shape outline)
9. colorFill (color for shape fill)
The list of possible shapeNames is:
- SQUARE
TRIANGLEUP
TRIANGLEDN
CIRCLE
DIAMONDVERTICAL
Chris.
-
- Posts: 212
- Joined: Mon Nov 29, 2010 9:21 pm
Re: How does one draw a line and square on a chart
Here's another way to draw a horizontal line.
This is a script that draws a horizontal line at the lowest low of the last N Bars:
Parameter tab:
N Double 25 1 10000
Here it is in action:
This is a script that draws a horizontal line at the lowest low of the last N Bars:
Code: Select all
ll:= LLV(L, N);
lastll:= ll.LASTVALUE;
curbar:= COUNT(C, 0);
countbars:= COUNT(C, 0).LASTVALUE;
myval: IF(curbar > countbars - N, lastll, NAN);
N Double 25 1 10000
Here it is in action: