variable
:zs=
c
,maxhl=
c
,maxlow=
c
;
DISTL:=
NEWLBARS
(
L
,
1
);
DISTH:=
NEWHBARS
(
H
,
1
);
HI20:=
REF
(
HHV
(
H
,
20
),
1
);
LO20:=
REF
(
LLV
(
L
,
20
),
1
);
GBD1:=
REF
(
L
,DISTL);
GBD2:=
REF
(GBD1,DISTL);
GBD:=
IF
(GBD2>
0
,
MAX
(
LLV
(
L
,
20
),GBD2),
LLV
(
L
,
20
));
GBG1:=
REF
(
H
,DISTH);
GBG2:=
REF
(GBG1,DISTH);
GBG:=
IF
(GBG2>
0
,
MIN
(
HHV
(
H
,
20
),GBG2),
HHV
(
H
,
20
));
Sar1:
SAR
(
10
,
2
,
20
),
CIRCLEDOT
;
DIFF :=
EMA
(
CLOSE
,
12
) -
EMA
(
CLOSE
,
26
);
DEA :=
EMA
(DIFF,
9
);
MACD :=
2
*(DIFF-DEA);
con1:=
any
(
ref
(Sar1>
high
,
1
)
and
Sar1<
high
,
3
)=
1
;
con2:=
any
(
cross
(diff,dea),
3
)=
1
and
diff<
5
;
if
holding
>
0
and
(
low
<zs)
then
sell
(
1
,
1
,
marketr
);
if
holding
<
0
and
(
high
>zs)
then
sellshort
(
1
,
1
,
marketr
);
if
con1
and
con2
and
holding
=
0
then
begin
buy
(
1
,
1
,
market
);
zs:=GBD;
maxhl:=
high
;
end
if
开空条件
and
holding
=
0
then
begin
buyshort
(
1
,
1
,
market
);
zs:=GBG;
maxlow:=
low
;
end
if
holding
>
0
and
high
>maxhl
and
GBD>zs
then
begin
zs:=GBD;
maxhl:=
high
;
end
if
holding
<
0
and
low
<maxlow
and
GBG<zs
then
begin
zs:=GBG;
maxlow:=
low
;
end
止损线:zs;