怎么把 图表策略 改写成后台策略呢 [金字塔]
- 咨询内容:
代码如下:
//中间变量
INPUT:N(16,1,30,1),K1(0.4,0.1,1,0.1),K2(0.8,0.1,1,0.1),NMIN(6,1,10,1),SS(1000,100,1000,100);
CYC:=BARSLAST(DATE<>REF(DATE,1))+1;
LHIGH:=CALLSTOCK(STKLABEL,VTHIGH,6,-1);
LLOW:=CALLSTOCK(STKLABEL,VTLOW,6,-1);
LCLOSE:=CALLSTOCK(STKLABEL,VTCLOSE,6,-1);
TOPEN:=VALUEWHEN(CYC=1,OPEN);
HH:=HHV(LHIGH,N);//N日HIGH的最高价
HC:=HHV(LCLOSE,N);//N日CLOSE的最高价
LC:=LLV(LCLOSE,N);//N日CLOSE的最低价
LL:=LLV(LLOW,N);//N日LOW的最低价
MOVING:=MAX(HH-LL,HC-LL);//RANGE
T1:=TIME>=091000 AND TIME<=145200;
T2:=TIME>=145400 AND TIME<=150000;
HOLDER:=SS;
UP:TOPEN+K1*MOVING;
DOWN:TOPEN-K2*MOVING;
BUYCON:=C>UP AND HOLDING=0 ;
BUYSHORTCON:=C<DOWN AND HOLDING=0 ;
VARIABLE:A:=0;
VARIABLE:B:=0;
VARIABLE:MAXP:=0;
VARIABLE:P:=0;
VARIABLE:MAXP:=0;
VARIABLE:DOWN:=;
///每天的 开盘的时候 持仓为0 且没有开过仓
IF TIME >=090000 AND TIME <=090200 THEN BEGIN
B:=0;//A 代表是否有仓位 b代表是否开过仓位
A:=0;
END
///
//持有空仓的情况
IF HOLDING=0 THEN BEGIN
IF T1 THEN BEGIN
IF BUYCON THEN BEGIN
BUY( B=0 AND A=0,HOLDER,MARKET);
A:=1;
B:=1;
P:=0;
MAXP:=0;
END
IF BUYSHORTCON THEN BEGIN
BUYSHORT( B=0 AND A=0,HOLDER,MARKET);
A:=-1;
B:=1;
P:=0;
MAXP:=0;
END
END
END
IF HOLDING>0 THEN BEGIN
IF T1 THEN BEGIN
//最高价格 浮亏10跳 止盈操作
If ENTERBARS>0 then begin
{
IF DYNAINFO( 7) >A THEN BEGIN//MAKE A MAX
A:= DYNAINFO( 7);
END
IF A - DYNAINFO( 7) >2 * MINDIFF THEN BEGIN//IF BIGGER THEN SELL
SELL(1,HOLDER,MARKET);
A:=0;
B:=1;
MAXP:=0;
END
}
//
////////+百分比止盈
P:=(DYNAINFO( 7)-AVGENTERPRICE())/AVGENTERPRICE() *100;
IF P>MAXP THEN BEGIN
MAXP=P;
DOWN:=(MAXP-P)/MAXP*100;
END
IF DOWN >=20 THEN BEGIN
SELL(1,HOLDER,C);
MAXP:=0;
P:=0;
A:=0;
B:=1;
END
///////////////////////
//浮亏10跳 止损
IF ( AVGENTERPRICE()- DYNAINFO( 7)>10*MINDIFF) THEN BEGIN
SELL(1,HOLDER,MARKET);
MAXP:=0;
P:=0;
A:=0;
B:=1;
END
end
//
END
IF T2 THEN BEGIN
SELL(1,HOLDER,MARKET);
A:=0;
B:=1;
END
END
IF HOLDING<0 THEN BEGIN
IF T1 THEN BEGIN
IF ( DYNAINFO( 7)-AVGENTERPRICE()>10*MINDIFF) THEN BEGIN
SELLSHORT(1,HOLDER,MARKET);
A:=0;
B:=1;
END
END
IF T2 THEN BEGIN
SELLSHORT(1,HOLDER,MARKET);
A:=0;
B:=1;
END
END
当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;//输出当前资产,但不影响坐标最高最低值
- 金字塔客服:
INPUT:N(16,1,30,1),K1(0.4,0.1,1,0.1),K2(0.8,0.1,1,0.1),NMIN(6,1,10,1),SS(1000,100,1000,100);
CYC:=BARSLAST(DATE<>REF(DATE,1))+1;
LHIGH:=CALLSTOCK(STKLABEL,VTHIGH,6,-1);
LLOW:=CALLSTOCK(STKLABEL,VTLOW,6,-1);
LCLOSE:=CALLSTOCK(STKLABEL,VTCLOSE,6,-1);
TOPEN:=VALUEWHEN(CYC=1,OPEN);
HH:=HHV(LHIGH,N);//N日HIGH的最高价
HC:=HHV(LCLOSE,N);//N日CLOSE的最高价
LC:=LLV(LCLOSE,N);//N日CLOSE的最低价
LL:=LLV(LLOW,N);//N日LOW的最低价
MOVING:=MAX(HH-LL,HC-LL);//RANGE
T1:=TIME>=091000 AND TIME<=145200;
T2:=TIME>=145400 AND TIME<=150000;
HOLDER:=SS;
UP:TOPEN+K1*MOVING;
DOWN:TOPEN-K2*MOVING;
//C>UP AND HOLDING=0:=C>UP AND HOLDING=0 ;
//C<DOWN AND HOLDING=0:=C<DOWN AND HOLDING=0 ;
globalvariable:A:=0;
globalvariable:B:=0;
globalvariable:MAXP:=0;
globalvariable:P:=0;
globalvariable:MAXP:=0;
globalvariable:DOWN:=;
///每天的 开盘的时候 持仓为0 且没有开过仓IF TIME >=090000 AND TIME <=090200 THEN BEGIN
B:=0;//A 代表是否有仓位 b代表是否开过仓位
A:=0;
END
/////持有空仓的情况
IF 1 THEN BEGIN
IF T1 THEN BEGIN
IF C>UP AND tbuyHOLDING(0)=0 THEN BEGIN
tBUY( B=0 AND A=0,HOLDER,mkt);
A:=1;
B:=1;
P:=0;
MAXP:=0;
END
IF C<DOWN AND tsellHOLDING(0)=0 THEN BEGIN
tBUYSHORT( B=0 AND A=0,HOLDER,mkt);
A:=-1;
B:=1;
P:=0;
MAXP:=0;
END
END
ENDIF tbuyHOLDING(0)>0 THEN BEGIN
IF T1 THEN BEGIN
//最高价格 浮亏10跳 止盈操作
If tenterbars>0 then begin
{
IF DYNAINFO( 7) >A THEN BEGIN//MAKE A MAX
A:= DYNAINFO( 7);
END
IF A - DYNAINFO( 7) >2 * MINDIFF THEN BEGIN//IF BIGGER THEN SELL
SELL(1,HOLDER,mkt);
A:=0;
B:=1;
MAXP:=0;
END
}
//
////////+百分比止盈P:=(DYNAINFO( 7)-tAVGENTERPRICE())/tAVGENTERPRICE() *100;
IF P>MAXP THEN BEGIN
MAXP:=P;
DOWN:=(MAXP-P)/MAXP*100;
END
IF DOWN >=20 THEN BEGIN
tSELL(1,HOLDER,lmt,C);
MAXP:=0;
P:=0;
A:=0;
B:=1;
END
///////////////////////
//浮亏10跳 止损
IF ( tAVGENTERPRICE()- DYNAINFO( 7)>10*MINDIFF) THEN BEGIN
tSELL(1,HOLDER,mkt);
MAXP:=0;
P:=0;
A:=0;
B:=1;
END
end
//
END
IF T2 THEN BEGIN
tSELL(1,HOLDER,mkt);
A:=0;
B:=1;
END
END
IF tsellHOLDING(0)>0 THEN BEGIN
IF T1 THEN BEGIN
IF ( DYNAINFO( 7)-tAVGENTERPRICE()>10*MINDIFF) THEN BEGIN
tSELLSHORT(1,HOLDER,mkt);
A:=0;
B:=1;
END
END
IF T2 THEN BEGIN
tSELLSHORT(1,HOLDER,mkt);
A:=0;
B:=1;
END
END - 用户回复:
你好 为了更快的买入
能都把 c>up 改为 dynainfo(7)>up 呢
- 网友回复:
在后台里面这两效果一样
- 网友回复: 不一样吧 dynainfo(7) 会不断的用最新market去填充 C只是每分钟的收盘价格而已
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容