In the strategy signal, often use the arrows to express the Open warehouse (many, empty) and other information icons. If it can be shown concretely in the picture, it is a very intuitive expression, which is beneficial to the more accurate understanding and contrast of the choice.
One, how to draw up and down arrows.
Specifically, the arrow function.
The relevant parameters are as follows:
Arrow (x, y, dx, dy, **kwargs), is the Zhihua coordinates from (x, y) to (x + dx, y + dy).
Among them, the common parameters (for example) have (fill in the following parameters can be disorderly order):
(1) The width of the head_width=0.01,=> arrow, note: Need to match the coordinates of the x axis
(2) width=0.00015, => arrow under the noodle-like width, note ditto
(3) head_length=0.07, => the length of the arrowhead, note: match the coordinates of the Y axis
(4) The smaller the overhang=0.5,=>, the arrows are more like real triangles, the padding is fuller, and the padding is less.
(5) head_starts_at_zero= "true",
(6) facecolor= "Red" => Arrow Color
(7) length_includes_head:= "true"; => How do you not want to have a long tail, you can use this to control.
(8) shape= "full"; Left side or right corner, or center (full)
The corresponding official description is as follows:
Constructor arguments
width:float (default:0.001)
width of full arrow tail
length_includes_head: [True | False] (default:false)
True If the IS-counted in calculating the length.
Head_width:float or None (default:3*width) Total width of the "full"
arrow head
head_length:float or None (Defaul t:1.5 * head_width)
length of Arrow head
shape: ["full", "left", "right"] (default: ' Full ')
draw the Left-hal F, right-half, or full arrow
overhang:float (default:0)
fraction This arrow is swept back (0 overhang mean s triangular shape). Can be negative or greater than one.
Head_starts_at_zero: [True | False] (default:false)
if True, the head starts being drawn at coordinate 0 instead to ending at coordinate 0.
Note that these parameters need to match the coordinate system of the x and Y axes, not the simple mechanical setting.
Two, Example 1
Using pyplot
x = [DateTime (2013,10,4):D Ates.millisecond (m):D atetime (2013,10,4,1);] # Generate Time array
x = Map (float64,x)/1000/60/60/24 # Convert time from milliseconds ' from ' Day ' 0 to ' Day ' 0< C2/>y = sin (2*pi*collect (0:2*pi/length (x): 2*pi-(2*pi/length (x)))
p = plot_date (x,y,linestyle= "-", marker= "None ", label=" Test Plot ")
arrow (X[convert (Int64,floor (Length (x)/2))],
0.4,
0.000
, 0.1,
Head_ width=0.001,
width=0.00015,
head_length=0.07,
overhang=0.5,
head_starts_at_zero= "true",
facecolor= "Red")
Three, example 2, if the parameter setting is not then
It should be noted that the same kind of arrow function parameters may have different effects.
Using Pyplot
x =1:1:20;
Y =sin (2x)
plot (x,y)
arrow (5,
-0.2,
0.0,
0.5,
head_width=0.001,
width= 0.00015,
head_length=0.07,
overhang=0.5,
head_starts_at_zero= "true",
facecolor= "Red")
Arrow. Make some modifications to the above parameters:
Arrow (5,
-0.2,
0.0,
0.5,
head_width=1,
width=0.3,
head_length=0.1,
overhang=0.5,
head_starts_at_zero= "true",
facecolor= "Red")
Get the following figure:
Iv. Example 3
Using Pyplot
x =1:1:20;
Y =2*x
Plot (x,y)
arrow (5,
0.0,
2,
head_width=2,
width=0.5,
head_ length=2,
overhang=0.5,
head_starts_at_zero= "true",
facecolor= "Red")
V. Example 4, get a shorter arrow
x = [DateTime (2013,10,4):D ates.millisecond:D atetime (2013,10,4,1);] # Generate Time array
x = Map (float64,x)/1000/60/60/24 # Convert time from milliseconds ' from ' Day ' 0 to ' Day ' 0< C1/>y = sin (2*pi*collect (0:2*pi/length (x): 2*pi-(2*pi/length (x)))
p = plot_date (x,y,linestyle= "-", marker= "None ", label=" Test Plot ")
#clf;
#close ();
Arrow (X[convert (Int64,floor (Length (x)/2))],
0.4,
0.000,
0.1,
shape= "full";
head_width=0.001,
width=0.00015,
length_includes_head= "true",
head_length=0.1,
overhang= 0.5,
head_starts_at_zero= "false",
facecolor= "Red")
Six, example 5, get a fuller arrow
Arrow (X[convert (Int64,floor (Length (x)/2))],
0.4,
0.000,
0.1,
shape= "full";
head_width=0.001,
width=0.00015,
length_includes_head= "true",
head_length=0.1,
overhang= 0.1,
head_starts_at_zero= "false",
facecolor= "Red")
Vii. Example 6: A specific application in the strategy signal
Draw a section of the code:
if mkTime = = Optime DX =tradedata[j].
Close * 0.005; If ls>0 # Open buy Pyplot.arrow (j,tradedata[j).
Close *0.995,0,dx,head_width=5,facecolor= "Red", length_includes_head= "true", head_length=2,overhang=0.1); Annotate ("Open buy", Xy=[j,tradedata[j]. close*0.995] Else Pyplot.arrow (j,tradedata[j).
close*1.005, 0,-dx,head_width=5,facecolor= "green", length_includes_head= "true", head_length=2,overhang=0.1); Annotate ("Open Sell", xy=[j,tradedata[j). Close * 1.005]) End ElseIf MkTime = = Cltime DX =tradedata[j].
Close * 0.005; If Ls>0 Pyplot.arrow (j,tradedata[j).
close*0.995, 0,dx,head_width=5,facecolor= "Red", length_includes_head= "true", head_length=2,overhang=0.1); Annotate ("Close buy", Xy=[j,tradedata[j]. Close*0.995] Else Pyplot.arrow (j,tradedata[j).
Close * 1.005,0,-dx,head_width=5,facecolor= "green", length_includes_head= "true", head_length=2,overhang=0.1); Annotate ("Close Sell", xy=[j,tradedata[j). CLOSE*1.005]) End