MA1:=
MA
(
CLOSE
,
5
);
MA2:=
MA
(
CLOSE
,
30
);
variable
:maxprofit1=
0
,maxprofit2=
0
;
IF
CROSS
(MA1,MA2)
and
holding
=
0
THEN
BEGIN
BUY
(
1
,
1
,
limit
,
c
);
maxprofit1:=
0
;
END
SELL
(
CROSS
(MA2,MA1),
0
,
limit
,
c
);
dwin:=
0
;
dwin2:=
0
;
if
holding
>
0
and
enterbars
>
0
then
begin
dwin:=(
c
-
enterprice
)/
enterprice
*
100
;
if
dwin>maxprofit1
then
maxprofit1:=dwin;
dwin2:=(maxprofit1-dwin)/maxprofit1*
100
;
end
多止损:
SELL
(dwin < -
2
,
0
,
limit
,
c
);
多止赢:
SELL
(dwin2 >=
60
and
openprofit
>
0
,
0
,
limit
,
c
);
IF
CROSS
(MA2,MA1)
and
holding
=
0
THEN
BEGIN
BUYSHORT
(
1
,
1
,
limit
,
c
);
maxprofit2:=
0
;
END
SELLSHORT
(
CROSS
(MA1,MA2),
0
,
limit
,
c
);
kwin:=
0
;
kwin2:=
0
;
if
holding
<
0
and
enterbars
>
0
then
begin
kwin:=(
enterprice
-
c
)/
enterprice
*
100
;
if
kwin > maxprofit2
then
maxprofit2:=kwin;
kwin2:=(maxprofit2-kwin)/maxprofit2*
100
;
end
空止损:
SELLSHORT
(kwin < -
2
,
0
,
limit
,
c
);
空止赢:
SELLSHORT
(kwin2 >=
60
and
openprofit
>
0
,
0
,
limit
,
c
);