Plots a segment that can expand to the right or to the left of the chart.
The second coordinates (x2 and y2) will be used to know in which direction the segment expand.
Syntax:
1 |
DRAWRAY(x1,y1,x2,y2) COLOURED(R,V,B,a) |
Coloured is optional.
Example 1:
Find and plot 2 trend lines based on highest high and lowest low of 2 different periods:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
defparam drawonlastbaronly = true period = 70 if islastbarupdate then y2 = lowest[period](low) yy2 = highest[period](high) //find the barindex of the highest high and lowest low for PERIOD for i = 0 to period do if low[i]=y2 then x2 = barindex[i] endif if high[i]=yy2 then xx2 = barindex[i] endif next //find the barindex of the highest high and lowest low for half PERIOD for i = 0 to round(period/2) do if low[i]<y2 then y1 = low[i] x1 = barindex[i] else y1 = low x1 = barindex endif if high[i]>yy2 then yy1 = high[i] xx1 = barindex[i] else yy1 = high xx1 = barindex endif next endif //plots the 2 half segments (ray) DRAWray(x1,y1,x2,y2)coloured(255,10,10) DRAWray(xx1,yy1,xx2,yy2)coloured(255,10,10) RETURN |
The lines can be expanded to the left of the chart:
or to the right if the coordinates of the first point are the second ones in the instruction:
1 2 3 |
// x1 and y1 are the coordinates of the segment point that is on the right of the chart: DRAWray(x2,y2,x1,y1)coloured(255,10,10) |
Example 2:
1 2 3 4 5 |
//extand to the right: white line DRAWRAY(barindex[10], close[10], barindex[0], low[0]) //extand to the left: red line DRAWRAY(barindex[5], close[5], barindex[21], close[21]) coloured(255,0,0) |