以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  本策略为双向开仓策略更改为只开多,只开空两个单向策略,谢谢  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=183107)

--  作者:代人发贴
--  发布时间:2020/11/20 14:29:52
--  本策略为双向开仓策略更改为只开多,只开空两个单向策略,谢谢

本策略为双向开仓策略,麻烦更改为只开多,只开空两个单向策略,谢谢

 

 

 

input:S(10,1,10,1);

时间:=TIME;

SHORT:=1;

LONG:=3;

M:=3;

DIF:=(EMA(CLOSE,SHORT) - EMA(CLOSE,LONG));

DEA:=EMA(DIF,M);

MACD:=(2 * (DIF - DEA));

KK:=IF((DIF > DEA),3,-(3));

JCSC:=((((M - 1) / (M + 1)) * DEA) / (1 - (2 / (M + 1))));

DD:=(((MACD / 2) + ((DEA * (M - 1)) / (M + 1))) / (1 - (2 / (M + 1))));

拐头:=(((((DIF * (SHORT + 1)) * (LONG + 1)) - (((LONG + 1) * (SHORT - 1)) * EMA(CLOSE,SHORT))) + (((SHORT + 1) * (LONG - 1)) * EMA(CLOSE,LONG))) / (2 * ((LONG + 1) - (SHORT + 1))));

TYP:=(((HIGH + LOW) + (2 * CLOSE)) / 4);

龙线:EMA(TYP,12),COLORMAGENTA,LINETHICK2;

最高价:=HHV(HIGH,(TIME = 10000));

最低价:=LLV(LOW,(TIME = 10000));

A:=REF(HHV(HIGH,最高价),2);

AA:=SYSPARAM(4);

B:=REF(LLV(LOW,最低价),2);

BB:=SYSPARAM(5);

ZJ1:=(((HIGH + LOW) + (2 * CLOSE)) / 4);

ZJ2:=(((ZJ1 - EMA(ZJ1,59)) / STD(ZJ1,59)) * 100);

ZJ3:=EMA(ZJ2,10);

ZJ4:=EMA(ZJ3,4);

ZJ5:=EMA(ZJ4,4);

ZJ6:=(((3 * ZJ4) - (2 * ZJ5)) / 2);

VAR1:=IF((ZJ6 > 99.99),(AA * 1),AA);

VAR2:=IF((ZJ6 < (0 - 99.99)),(BB * 1),BB);

:=(VAR1 - VAR2);

1:=((差 * 0.99) + VAR2);

2:=((差 * 0.01) + VAR2);

最高价1:=HHV(VAR1,(TIME = 10000));

最低价1:=LLV(VAR2,(TIME = 10000));

开多1:=CROSS(拐头,百2);

开空1:=CROSS(百1,拐头);

3:=REFDATE(最高价1,DATE,0);

4:=REFDATE(最低价1,DATE,0);

VARIABLE:SS:=1;

VARIABLE:NUM:=0;

IF (SS = S) THEN

BEGIN

NUM:=0;

END

IF (SS = 1) THEN

BEGIN

NUM:=1;

END

IF (开空1 AND (TIME < 185000)) THEN

BEGIN

SELL(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

BUYSHORT(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (开多1 AND (TIME < 185000)) THEN

BEGIN

SELLSHORT(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

BUY(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (TIME > 185000) THEN

BEGIN

SELL(1,HOLDING,market);

SELLSHORT(1,HOLDING,market);

END

 

 

{

KD:=;          //开多条件

PD:=;          //平多条件

KK:=;          //开空条件

PK:=;          //平空条件

 

 

平空:SELLSHORT(PK,1,THISCLOSE);                  //平空信号

开多:BUY(KD AND HOLDING=0,1,THISCLOSE);          //开多信号

平多:SELL(PD,1,THISCLOSE);                       //平多信号

开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE);     //开空信号

 

}

{

 


--  作者:FireScript
--  发布时间:2020/11/20 15:09:56
--  

前面部分不变,把开多的代码注释了就行了

VARIABLE:SS:=1;

VARIABLE:NUM:=0;

IF (SS = S) THEN

BEGIN

NUM:=0;

END

IF (SS = 1) THEN

BEGIN

NUM:=1;

END

IF (开空1 AND (TIME < 185000)) THEN

BEGIN

SELL(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

BUYSHORT(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (开多1 AND (TIME < 185000)) THEN

BEGIN

SELLSHORT(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

BUY(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (TIME > 185000) THEN

BEGIN

SELL(1,HOLDING,market);

SELLSHORT(1,HOLDING,market);

END

 



--  作者:FireScript
--  发布时间:2020/11/20 15:11:06
--  
 
多头:
前面部分代码不变,把下面这部分开空的代码注释了就行了

VARIABLE:SS:=1;

VARIABLE:NUM:=0;

IF (SS = S) THEN

BEGIN

NUM:=0;

END

IF (SS = 1) THEN

BEGIN

NUM:=1;

END

IF (开空1 AND (TIME < 185000)) THEN

BEGIN

SELL(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

//BUYSHORT(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (开多1 AND (TIME < 185000)) THEN

BEGIN

//SELLSHORT(1,HOLDING,market);

IF (HOLDING = 0) THEN

BEGIN

BUY(1,SS,market);

IF (NUM = 1) THEN

BEGIN

SS:=(SS + 0.5);

END

ELSE

BEGIN

IF (NUM = 0) THEN

BEGIN

SS:=(SS - 1);

END

END

END

END

IF (TIME > 185000) THEN

BEGIN
SELL(1,HOLDING,market);
END