欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件程序化交易实盘俱乐部 → 将此多头策略,添加一个空头策略,谢谢

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有4050人关注过本帖树形打印复制链接

主题:将此多头策略,添加一个空头策略,谢谢

帅哥哟,离线,有人找我吗?
秉蠡春秋
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:8 积分:0 威望:0 精华:0 注册:2020/10/29 11:39:59
将此多头策略,添加一个空头策略,谢谢  发帖心情 Post By:2020/10/30 7:50:54 [显示全部帖子]

//+++++++++++++++++++DD-LINK+++++++++++++++++++++++++++

//WARNING_DISABLE:9;
{===========================================================================================}
INPUT:T0(3,2,240,1),BMIN(1,1,100,1),BMAX(40,1,100,1);
HOLDING0:=IF(HOLDING<>DAYHOLDING,DAYHOLDING,HOLDING);
AVGENTERPRICE0:=IF(AVGENTERPRICE<>AVGENTERPRICE,AVGENTERPRICE,AVGENTERPRICE);
{===========================================================================================}
{
TR0:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)),NOAXIS;//,LINETHICK0;
ATR0:MA(TR0,14),NOAXIS;//,LINETHICK0;

TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)),NOAXIS;//,LINETHICK0;
ATR1:REF(MA(TR1,14),1),NOAXIS;//,LINETHICK0;
{===========================================================================================}
OPEND:="$OPEN#DAY";
CLOSED:="$CLOSE#DAY";
HIGHD:="$HIGH#DAY";
LOWD:="$LOW#DAY";
VOLD:="$VOL#DAY";

BZJ0:=ROUND( ( REF(CLOSED,0) * MULTIPLIER * (TACCOUNT(41)+TACCOUNT(42))/2 ) ),NOAXIS,LINETHICK0;
FY0:=OPENPROFIT,NOAXIS;//,LINETHICK0;
保0:BZJ0,NOAXIS,LINETHICK0;
浮0:FY0,NOAXIS,LINETHICK0;

ZCK0:=ROUND( ( (( CASH(0)+CASH(1) )/2) * (BMIN/100) ) / BZJ0 ),NOAXIS,LINETHICK0;
ZCK1:=ROUND( ( (( CASH(0)+CASH(1) )/2) * (BMAX/100) ) / BZJ0 ),NOAXIS,LINETHICK0;
基:ZCK0,NOAXIS,LINETHICK0;
极:ZCK1,NOAXIS,LINETHICK0;

ZCB0:=( (CASH(0)+CASH(1))/2 )/(ASSET),NOAXIS,LINETHICK0;
比:=ZCB0,NOAXIS,LINETHICK0;

JYF0:=GEGCHARGE('',REF(CLOSED,0),1,0)*2,NOAXIS,LINETHICK0;
费:JYF0,NOAXIS,LINETHICK0;

MMC0:=( (DYNAINFO(34)-DYNAINFO(28)) )*MULTIPLIER,NOAXIS,LINETHICK0;
差:MMC0,NOAXIS,LINETHICK0;

ZXBD:=DYNAINFO(208)*MULTIPLIER,NOAXIS,LINETHICK0;
//XS:( IF(JYF>=MMC,JYF,MMC)-IF(MMC>=JYF,JYF,MMC) )/IF(JYF>=MMC,JYF,MMC),NOAXIS,LINETHICK0;
//DC:(1+ROUND(IF(XS<=1,1,XS)))*( (DYNAINFO(34)-DYNAINFO(28)) ),NOAXIS,LINETHICK0;

{===========================================================================================}
仓:HOLDING0,NOAXIS,LINETHICK0;
资:ASSET,NOAXIS,LINETHICK1;
金:CASH(0),NOAXIS,LINETHICK0;
净:NETPROFIT,NOAXIS,COLORYELLOW,LINETHICK0;
浮:OPENPROFIT,NOAXIS,LINETHICK0;
幅:OPENPROFITPER,NOAXIS,LINETHICK0;
撤:MAXDRAWDOWN,NOAXIS,LINETHICK0;
幅0:MAXDRAWDOWNPCT,NOAXIS,LINETHICK0;
亏:GROSSLOSS,NOAXIS,LINETHICK0;
盈:BESTTRADE,NOAXIS,LINETHICK0;
回:ANNUALRETURNRATER,NOAXIS,LINETHICK0;
年:ANNUALRETURNRATE,NOAXIS,LINETHICK0;
风:=PROFITRISKRATIO,NOAXIS,LINETHICK0;
次:=TOTALDAYTRADE,NOAXIS,LINETHICK0;
{++++++++++++++++++++++++++++++++++}
HMIN:=ZCK0;
HMAX:=ZCK1;
H1:=HMIN;
H2:=H1*2;
H3:=H1*3;
{=============================================================================}
ZQ1:=IF(DATATYPE=1,1,0);
ZQ3:=IF(DATATYPE=17,3,0);
ZQ5:=IF(DATATYPE=2,5,0);
ZQ10:=IF(DATATYPE=18,10,0);
ZQ15:=IF(DATATYPE=3,15,0);
ZQ30:=IF(DATATYPE=4,30,0);
ZQ60:=IF(DATATYPE=5,60,0);
ZQF:=IF(DATATYPE=13,DATATYPEMORE(2),0);
ZQH:=IF(DATATYPE=11,DATATYPEMORE(1)*60,0);
ZQ:=ZQ1+ZQ3+ZQ5+ZQ10+ZQ15+ZQ30+ZQ60+ZQF+ZQH,NOAXIS;
CYC:=BARSLAST(DATE<>REF(DATE,1))+1,NOAXIS;
JY:=IF(HIGH+LOW-OPEN-CLOSE=0,0,1),NOAXIS;
TK:=TIME>OPENTIME(1) AND TIME<CLOSETIME(0)-10*100,NOAXIS;
TS:=TIME>=CLOSETIME(0)-10*100,NOAXIS;
F:="ZQ";
OPENMIN1:="$OPEN#MINF";
OPENDAY:="$OPEN#DAY";
OPENSTART:=IF(OPENMIN1=OPENDAY,1,0);
OST:=FILTER(OPENSTART,CYC);
KPJY:=HOLDING0=0 AND OST>=1 AND TK>=1 AND JY=1 AND CYC>=1;
SPJY:= TS=1;
{====================================================================================================}
//收盘:SELL(SPJY,HOLDING0,THISCLOSE);{CLOSE}
//开盘:BUY(KPJY,HMIN,THISCLOSE);{OPEN}
//SELLSHORT(SPJY,DAYHOLDING,THISCLOSE);{CLOSE}
//BUYSHORT(KPJY,1,THISCLOSE);{OPEN}
{============================================================================================}
//INPUT:N(1,1,100,1);
D:=T0;//10;//RAND(9)+5,NOAXIS,LINETHICK0;
隔:=D,NOAXIS,LINETHICK0;
D1:=IF(D<=2,2,D),NOAXIS,LINETHICK0;
D2:=RET(OPENMINUTES(CURRENTTIME),1),NOAXIS,LINETHICK0;
D3:=RET(OPENMINUTES(TIME),1),NOAXIS,LINETHICK0;
日:=D2,NOAXIS;//,LINETHICK0;
分:=D3,NOAXIS;//,LINETHICK0;
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
X0:=IF(HIGH+LOW-OPEN-CLOSE=0,0,1),NOAXIS,LINETHICK0;
X1:=REF(X0,1),NOAXIS,LINETHICK0;
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
A1:=OPENMINUTES(TIME)/D,NOAXIS,LINETHICK0;
A2:=INTPART(A1),NOAXIS,LINETHICK0;
A3:=FRACPART(A1),NOAXIS,LINETHICK0;
A4:=(A2/A3),NOAXIS,LINETHICK0;
A5:=(A2-D),NOAXIS,LINETHICK0;
A6:=IF((A4-A5)=D,1,0),NOAXIS,LINETHICK0;
{===========================================================================+}
BBUY:=OPEN-IF(AVGENTERPRICE0=0,OPEN,AVGENTERPRICE0),NOAXIS;
本 :=BBUY,NOAXIS,COLORBLUE;//,LINETHICK0;
本0:IF(AVGENTERPRICE=0,OPEN,AVGENTERPRICE),COLORRED;//,NOAXIS;//,LINETHICK0;
{============================================================}
B0:=1*(DYNAINFO(34)-DYNAINFO(28)),NOAXIS,LINETHICK0;
B1:=IF(B0<=0,MINDIFF,B0),NOAXIS,LINETHICK0;
差:=B1,NOAXIS;//,LINETHICK0;

{++++++++++++++++++++++++++++++++++++++}
{
FY1:FY0/BZJ0/1,NOAXIS;//,LINETHICK0;
FY2:FY0/BZJ0/2,NOAXIS;//,LINETHICK0;
FY3:FY0/BZJ0/3,NOAXIS;//,LINETHICK0;
FY4:FY0/BZJ0/4,NOAXIS;//,LINETHICK0;
FY5:FY0/BZJ0/5,NOAXIS;//,LINETHICK0;
FY6:FY0/BZJ0/6,NOAXIS;//,LINETHICK0;
//   FILTER((FY0>BZJ0),ENTERBARS)

{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}

KPD:=01 AND BBUY>B1*7 AND X1;
控平多:SELL(KPD ,HOLDING0/H3,THISCLOSE),NOAXIS,LINETHICK0;
//控平多:SELL( HOLDING0>0 AND FY0>=BZJ0 AND X1,(HOLDING0)/H3,THISCLOSE),NOAXIS,LINETHICK0;
{===========================================================================}
//开盘:SELL((D2+D3)=D2+1,HOLDING,MARKETR),NOAXIS,LINETHICK0;
随机开多:BUY(  HOLDING0=0 AND X1 AND A6,BMIN,THISCLOSE),NOAXIS,LINETHICK0;
{===========================================================================}
控加多0:BUY(01<HOLDING0<02 AND (BBUY+B1*05)<-B1*07 AND X1 AND A6,H2,THISCLOSE),NOAXIS,LINETHICK0;
控加多1:BUY(02<HOLDING0<03 AND (BBUY+B1*07)<-B1*11 AND X1 AND A6,H3,THISCLOSE),NOAXIS,LINETHICK0;
控加多2:BUY(03<HOLDING0<05 AND (BBUY+B1*11)<-B1*13 AND X1 AND A6,H1,THISCLOSE),NOAXIS,LINETHICK0;
控加多3:BUY(05<HOLDING0<07 AND (BBUY+B1*13)<-B1*17 AND X1 AND A6,H2,THISCLOSE),NOAXIS,LINETHICK0;
控加多4:BUY(07<HOLDING0<11 AND (BBUY+B1*17)<-B1*19 AND X1 AND A6,H3,THISCLOSE),NOAXIS,LINETHICK0;
控加多5:BUY(11<HOLDING0<13 AND (BBUY+B1*19)<-B1*23 AND X1 AND A6,H1,THISCLOSE),NOAXIS,LINETHICK0;
控加多6:BUY(13<HOLDING0<17 AND (BBUY+B1*23)<-B1*29 AND X1 AND A6,H2,THISCLOSE),NOAXIS,LINETHICK0;
控加多7:BUY(17<HOLDING0<19 AND (BBUY+B1*29)<-B1*31 AND X1 AND A6,H3,THISCLOSE),NOAXIS,LINETHICK0;
控加多8:BUY(19<HOLDING0<23 AND (BBUY+B1*31)<-B1*37 AND X1 AND A6,H1,THISCLOSE),NOAXIS,LINETHICK0;
控加多9:BUY(23<HOLDING0<29 AND (BBUY+B1*37)<-B1*41 AND X1 AND A6,H2,THISCLOSE),NOAXIS,LINETHICK0;
{===========================================================================}
{
JD:=#KK-LINK.KPK(1)#;
加多0:BUY(JD=1 AND X1 AND A6,H2,THISCLOSE),NOAXIS,LINETHICK0;
{===========================================================================}
{
控平多0:SELL(IF( HOLDING0>HMAX/3,1,0) AND FILTER((BBUY>B1*0),ENTERBARS) AND X1,HOLDING0/H2,THISCLOSE),NOAXIS,LINETHICK0;
控平多1:SELL(IF( HOLDING0>HMAX/2,1,0) AND FILTER((BBUY>B1*0),ENTERBARS) AND X1,HOLDING0/H2,THISCLOSE),NOAXIS,LINETHICK0;
//控平多3:SELL(IF( HOLDING0>HMAX/1,1,0) AND FILTER((BBUY>B1*0),ENTERBARS) AND X1,HOLDING0/H2,THISCLOSE),NOAXIS,LINETHICK0;

{=============================================================================}


{===============================================================================}
//开盘0:SELL((D2+D3)=D2+1,HOLDING,MARKETR),NOAXIS,LINETHICK0;
//收盘清仓0:SELL( (D2-D3)=1 ,HOLDING0,THISCLOSE),NOAXIS,LINETHICK0;

//收盘清仓:SELL( SPJY ,HOLDING0,THISCLOSE),NOAXIS,LINETHICK0;
{======================================================================================}











{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
//开盘全平:SELL((D2+D3)=D2+1,HOLDING,MARKETR),NOAXIS,LINETHICK0;
//开多:BUY(X1 AND A6,1,MARKETR),NOAXIS,LINETHICK0;
//加多:BUY(B1<0 AND A6,1,MARKETR),NOAXIS,LINETHICK0;
//控平多:SELL(B1>=5,HOLDING/2,MARKETR),NOAXIS,LINETHICK0;
//收盘清仓:SELL((D2-D3)<=1 ,HOLDING,MARKETR),NOAXIS,LINETHICK0;
{============================================================================}

{===========================================================================}
//开盘全平:SELL((D2+D3)=D2+1,HOLDING,THISCLOSE),ORDERQUEUE,NOAXIS,LINETHICK0;
//开多:BUY(X1 AND A6,1,THISCLOSE),ORDERQUEUE,NOAXIS,LINETHICK0;
//加多:BUY(B1<0 AND A6,1,THISCLOSE),ORDERQUEUE,NOAXIS,LINETHICK0;
//控平多:SELL(B1>=5,HOLDING/2,THISCLOSE),ORDERQUEUE,NOAXIS,LINETHICK0;
//收盘清仓:SELL((D2-D3)<=1 ,HOLDING,THISCLOSE),ORDERQUEUE,NOAXIS,LINETHICK0;
{============================================================================}


//DATAPERIAD
//BUY(X1 AND OPENMINUTES(TIME)=0,1,THISCLOSE);
{
//SELL(X AND ENTERBARS=2,0,THISCLOSE),NOAXIS,LINETHICK0;
//固定止损部分************************

//止盈
IF OPEN-AVGENTERPRICE>100*MINDIFF THEN BEGIN
SELL(1,HOLDING,THISCLOSE);
END

//止损
IF AVGENTERPRICE-OPEN>10*MINDIFF THEN BEGIN
SELL(1,HOLDING,THISCLOSE);
END
//BUYSHORT(A6,1,THISCLOSE),NOAXIS,LINETHICK0;
//SELLSHORT(ENTERBARS=9,0,THISCLOSE),NOAXIS,LINETHICK0;
}

//A:(TIMETOT0(DYNAINFO(207)+D)-REF(TIME0,1)),NOAXIS,LINETHICK0;

//CD1:(HOLDING=0) OR ENTERBARS=5,NOAXIS,LINETHICK0;
//CD2:(HOLDING=0) OR EXITBARS=5,NOAXIS,LINETHICK0;

//BUY(CD1,1,THISCLOSE);
//SELL(CD2,1,THISCLOSE);
//BUYSHORT(CD,1,MARKET);

//移动止损部分************************
//求出持仓以来的最高价或最低价,通过与当前价做比较,判断资金回落的幅度
//DTYDZS:=(HHV(H,ENTERBARS)-CLOSE)/AVGENTERPRICE>=0.01;
//KTYDZS:=(CLOSE-LLV(L,ENTERBARS))/AVGENTERPRICE>=0.01;
//SELL(DTYDZS,0,THISCLOSE);
//SELLSHORT(KTYDZS,0,THISCLOSE);

//PJ:IF(AVGENTERPRICE=0,OPEN,AVGENTERPRICE)-OPEN,NOAXIS;
//PJ:AVGENTERPRICE,NOAXIS;

{
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);     //开空信号

}
{
信号语句排列规则——先平后开
“费率设置”按钮——用于合理设置模型“费率”,以便在图形上正确输出如下帐户信息:

持仓:HOLDING,LINETHICK0;
资产:ASSET,NOAXIS;
可用现金:CASH(0),LINETHICK0;

 回到顶部