等级: 新手上路
- 注册:
- 2021-6-24
- 曾用名:
|
BPK:cross(ma(c,20),ma(c,30));
SPK:cross(ma(c,30),ma(c,20));
lots:=4;
IF holding<=0 and BPK THEN
BEGIN
sellshort(holding<0,0,marketr); //卖平空单
Buy(holding=0,lots,marketr); //买开多单
nn:=1;
END
IF holding>=0 and SPK THEN
BEGIN
sell(holding>0,0,marketr); //买平多单
buyShort(holding=0,lots,MARKETr);//卖开空单
nn:=1;
END
这段代码是双均线开平,没问题(交易记录见图1)。我是想当收益超过1%,平掉一般的仓位 加了如下代码:
BPK:cross(ma(c,20),ma(c,30));
SPK:cross(ma(c,30),ma(c,20));
lots:=4;
IF holding<=0 and BPK THEN
BEGIN
sellshort(holding<0,0,marketr); //卖平空单
Buy(holding=0,lots,marketr); //买开多单
nn:=1;
END
IF holding>=0 and SPK THEN
BEGIN
sell(holding>0,0,marketr); //买平多单
buyShort(holding=0,lots,MARKETr);//卖开空单
nn:=1;
END
SP1:=c>=ENTERPRICE*0.99;
BP1:=C<=ENTERPRICE*1.01;
IF holding=4 and nn=1 THEN
begin;
SELL(SP1,lots/2,market);
nn1:=0;
end;
IF holding=-4 and nn=1 THEN
begin;
SELLSHORT(BP1,lots/2,market);
nn1:=0;
end;
这样的话 的效果是开仓的同一根K线 直接平掉一半(交易记录见图2),我的问题出在哪?怎么写能达到我得目的
|
-
图2
-
图1
|