我完全没有改动过, 为什么软件里的02.双向海龟交易系统-后台 这个策略输出的 debugfile.txt 有错误? [金字塔]
-
咨询内容:
我完全没有改动过, 为什么软件里的02.双向海龟交易系统-后台 这个策略输出的 debugfile.txt 有错误? 看附件
-
金字塔客服:
请表述清楚。具体什么问题
来源:程序化久久网( WWW.CXH99.COM )
-
用户回复:
你后台交易系统模板里面有一个叫双向海龟系统, 不但.“STKLABEL”输出字符串不能正常输出, 而且输出附件的“debugfile.txt” 也是显示有错误的, 请看附件
-
网友回复:
附件在哪?你直接把你修改后的代码贴出来,我们看下。你是怎么输出的。
-
网友回复:
//声明参数
INPUT : T20(20,15,60,1) ; //进场的周期
INPUT : T10(10,10,30,1); //出场的周期
INPUT : ATRLEN(20,15,30,1) ;
INPUT : POSNUM(2,1,20,1) ; //每次交易的手数//声明变量
BUYORDERTHISBAR := 0 ; //当前BAR有过交易VARIABLE : _DEBUG = 1 ; //是否输出前台交易指令
VARIABLE : _TDEBUG = 1 ; //是否输出后台交易指令
VARIABLE : _DEBUGOUT = 1 ; //是否输出后台交易的调试信息
VARIABLE : MYE***YPRICE =0 ; //开仓价格
VARIABLE : MYEXITPRICE =0 ; //平仓价格VARIABLE : TURTLEUNITS=0 ; //交易单位
VARIABLE : POSITION=0 ; //仓位状态
//0表示没有仓位,1表示持有多头, -1表示持有空头VARIABLE : T20HI=CLOSE ; //20周期的高点
VARIABLE : T20LO=CLOSE ; //20周期的低点VARIABLE : T10HI=CLOSE ; //10周期的高点
VARIABLE : T10LO=CLOSE ; //10周期的低点//准备需要计算的变量
T20HI := REF(HHV(H,T20),1) ;
T20LO := REF(LLV(L,T20),1) ;T10HI := REF(HHV(H,T10),1) ;
T10LO := REF(LLV(L,T10),1) ;***GTR := REF(MA(TR,ATRLEN),1) ;
//采用全局变量保存最后一根K线的计算状态
STRE***YBARPOS:STRCAT(STKLABEL,'E***YBARPOS') ;
STREXITBARPOS:STRCAT(STKLABEL,'EXITBARPOS') ;
STRPREE***YPRICE:STRCAT(STKLABEL,'PREE***YPRICE') ;
STRTURTLEUNITS:STRCAT(STKLABEL,'TURTLEUNITS') ;
STRPOSITION:STRCAT(STKLABEL,'POSITION') ;
STRPREN:STRCAT(STKLABEL,'PREN') ;
{IF NOT ( WORKMODE=1 ) THEN BEGIN
DRAWTEXTEX(1 ,0 ,0 ,0 ,'提示:本公式仅用于后台交易!' ),COLORYELLOW ;
EXIT ;
END}//开始执行时 初始化数据
//注意:第一个数据的BARPOS=1
IF BARPOS=1 THEN BEGIN
//POSITION := 0 ;END //IF
//如果当前棒是最后一根K线,执行
IF ISLASTBAR THEN BEGIN// 如果最后一根K线发生过出场信号,则那一根K线不再交易
IF EXTGBDATA(STREXITBARPOS) = BARPOS THEN BEGIN
GOTO CONTINUELINE ;
END//恢复上一秒计算时保存的数据
//如果记录的进场BARPOS和当前的相等,说明上一个进场信号也是最后一根K线发出的。
IF EXTGBDATA(STRE***YBARPOS) = BARPOS THEN BEGIN
MYE***YPRICE := EXTGBDATA(STRPREE***YPRICE) ;
TURTLEUNITS := EXTGBDATA(STRTURTLEUNITS) ;
POSITION := EXTGBDATA(STRPOSITION) ;
N := EXTGBDATA(STRPREN) ;
END
//如果当前是没有持仓的状态
IF POSITION=0 AND BARPOS>T20 AND H>L THEN BEGIN
//建立多头进场条件
LONG := H > T20HI ;
//多头进场符合
IF LONG THEN BEGIN
MYE***YPRICE := IF(OPEN>T20HI+MINDIFF ,OPEN ,T20HI+MINDIFF ) ;
POSITION := 1 ;
TURTLEUNITS := 1 ;
N := ***GTR ;
TBUY( _TDEBUG,POSNUM,LMT,H),ALLOWREPEAT ;EXTGBDATASET(STRE***YBARPOS,BARPOS ) ;
EXTGBDATASET(STRPREE***YPRICE,MYE***YPRICE ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;
EXTGBDATASET(STRPREN,N ) ;
END //IF多头进场符合
//建立空头进场条件
SHORT := L < T20LO ;
//空头进场符合
IF SHORT AND POSITION=0 THEN BEGIN
MYE***YPRICE := IF(OPEN<T20LO-MINDIFF ,OPEN ,T20LO-MINDIFF ) ;
POSITION := -1 ;
TURTLEUNITS := 1 ;
N := ***GTR ;
TBUYSHORT( _TDEBUG,POSNUM,LMT,L),ALLOWREPEAT;EXTGBDATASET(STRE***YBARPOS,BARPOS ) ;
EXTGBDATASET(STRPREE***YPRICE,MYE***YPRICE ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;
EXTGBDATASET(STRPREN,N ) ;
END //IF空头进场符合
GOTO CONTINUELINE ;
END //IF如果当前是没有持仓的状态
//如果当前持有多头仓位的状态
IF POSITION=1 AND BARPOS>T20 AND H>L THEN BEGIN
//多头加仓条件
IF (HIGH>MYE***YPRICE+0.5*N) AND TURTLEUNITS<4 THEN BEGIN
MYE***YPRICE := IF(OPEN>MYE***YPRICE+0.5*N ,OPEN ,MYE***YPRICE+0.5*N ) ;
MYE***YPRICE := CEILING(MYE***YPRICE/MINDIFF)*MINDIFF ;
TURTLEUNITS := TURTLEUNITS+1 ;
TBUY( _TDEBUG,POSNUM,LMT,H),ALLOWREPEAT ;EXTGBDATASET(STRE***YBARPOS,BARPOS ) ;
EXTGBDATASET(STRPREE***YPRICE,MYE***YPRICE ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;
END //IF多头加仓条件
//建立多头离场条件
LONGX1 := (LOW < T10LO) ;
IF LONGX1 AND EXTGBDATA(STRE***YBARPOS)<>BARPOS AND EXTGBDATA(STREXITBARPOS)<>BARPOS THEN BEGIN
MYEXITPRICE := IF(OPEN<T10LO-MINDIFF ,OPEN ,T10LO-MINDIFF ) ;
POSITION := 0 ;
TURTLEUNITS := 0 ;
TSELL( _TDEBUG ,0,LMT,L),ALLOWREPEAT;
EXTGBDATASET(STREXITBARPOS,BARPOS ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;END
//建立多头止损条件
LONGX2 := (LOW<MYE***YPRICE-2*N) ;
IF LONGX2 AND POSITION=1 AND EXTGBDATA(STRE***YBARPOS)<>BARPOS AND EXTGBDATA(STREXITBARPOS)<>BARPOS THEN BEGIN
MYEXITPRICE := IF(OPEN<MYE***YPRICE-2*N ,OPEN ,MYE***YPRICE-2*N ) ;
MYEXITPRICE := FLOOR(MYEXITPRICE/MINDIFF)*MINDIFF ;
POSITION := 0 ;
TURTLEUNITS := 0 ;TSELL( _TDEBUG ,0,LMT,L),ALLOWREPEAT;
EXTGBDATASET(STREXITBARPOS,BARPOS ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;END
GOTO CONTINUELINE ;
END //IF如果当前持有多头仓位的状态//如果当前持有空头仓位的状态
IF POSITION = -1 AND BARPOS>T20 AND H>L THEN BEGIN
//空头加仓条件IF (LOW<MYE***YPRICE-0.5*N) AND TURTLEUNITS<4 THEN BEGIN
MYE***YPRICE := IF(OPEN<MYE***YPRICE-0.5*N ,OPEN ,MYE***YPRICE-0.5*N ) ;
MYE***YPRICE := FLOOR(MYE***YPRICE/MINDIFF)*MINDIFF ;
TURTLEUNITS := TURTLEUNITS+1 ;TBUYSHORT( _TDEBUG,POSNUM,LMT,L),ALLOWREPEAT;
EXTGBDATASET(STRE***YBARPOS,BARPOS ) ;
EXTGBDATASET(STRPREE***YPRICE,MYE***YPRICE ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;END //IF空头加仓条件
//建立空头离场条件
SHORTX1 := H > T10HI ;
IF SHORTX1 AND EXTGBDATA(STRE***YBARPOS)<>BARPOS AND EXTGBDATA(STREXITBARPOS)<>BARPOS THEN BEGIN
MYEXITPRICE := IF(OPEN>T10HI+MINDIFF ,OPEN ,T10HI+MINDIFF ) ;
POSITION := 0 ;
TURTLEUNITS := 0 ;TSELLSHORT( _TDEBUG,0,LMT,H),ALLOWREPEAT;
EXTGBDATASET(STREXITBARPOS,BARPOS ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;END
//建立空头止损条件
SHORTX2 := HIGH > MYE***YPRICE + 2*N ;
IF SHORTX2 AND POSITION = -1 AND EXTGBDATA(STRE***YBARPOS)<>BARPOS AND EXTGBDATA(STREXITBARPOS)<>BARPOS THEN BEGIN
MYEXITPRICE := IF(OPEN>MYE***YPRICE+2*N ,OPEN ,MYE***YPRICE+2*N ) ;
MYEXITPRICE := CEILING(MYEXITPRICE/MINDIFF)*MINDIFF ;
POSITION := 0 ;
TURTLEUNITS := 0 ;TSELLSHORT( _TDEBUG,0,LMT,H),ALLOWREPEAT;
EXTGBDATASET(STREXITBARPOS,BARPOS ) ;
EXTGBDATASET(STRTURTLEUNITS,TURTLEUNITS ) ;
EXTGBDATASET(STRPOSITION,POSITION ) ;END
GOTO CONTINUELINE ;
END //IF如果当前持有空头仓位的状态//如果以上3种情形都没有成立,则直接结束本次判断
GOTO CONTINUELINE ;
END //IF如果当前棒是最后一根K线
//不是最后一根K线的情形
//如果当前是没有持仓的状态
IF POSITION=0 AND BARPOS>T20 AND H>L THEN BEGIN//建立多头进场条件
LONG := H > T20HI ;
//多头进场
IF LONG THEN BEGIN
MYE***YPRICE := IF(OPEN>T20HI+MINDIFF ,OPEN ,T20HI+MINDIFF ) ;
//BUY( _DEBUG,POSNUM,LIMITR,MYE***YPRICE+MINDIFF);
POSITION := 1 ;
TURTLEUNITS := 1 ;
N := ***GTR ;
BUYORDERTHISBAR := 1;END //IF
//建立空头进场条件
SHORT := L < T20LO ;
//空头进场
IF SHORT AND POSITION=0 THEN BEGIN
MYE***YPRICE := IF(OPEN<T20LO-MINDIFF ,OPEN ,T20LO-MINDIFF ) ;
//BUYSHORT( _DEBUG,POSNUM,LIMITR,MYE***YPRICE-MINDIFF);
POSITION := -1 ;
TURTLEUNITS := 1 ;
N := ***GTR ;
BUYORDERTHISBAR := 1;END
//不要跳转,让程序检查同一根K线是否可以加仓
//GOTO CONTINUELINE ;
END //IF
//如果当前持有多头仓位的状态IF POSITION=1 AND BARPOS>T20 AND H>L THEN BEGIN
//多头加仓条件
WHILE (HIGH>MYE***YPRICE+0.5*N) AND TURTLEUNITS<4 DO BEGIN
MYE***YPRICE := IF(OPEN>MYE***YPRICE+0.5*N ,OPEN ,MYE***YPRICE+0.5*N ) ;
MYE***YPRICE := CEILING(MYE***YPRICE/MINDIFF)*MINDIFF ;
//BUY( _DEBUG, POSNUM, LIMITR, MYE***YPRICE);
TURTLEUNITS := TURTLEUNITS+1 ;
BUYORDERTHISBAR := 1;
END //WHILE
//建立多头离场条件
LONGX1 := (LOW < T10LO) ;
IF LONGX1 AND BUYORDERTHISBAR=0 THEN BEGIN
MYEXITPRICE := IF(OPEN<T10LO-MINDIFF ,OPEN ,T10LO-MINDIFF ) ;
//SELL( _DEBUG ,0,LIMITR,MYEXITPRICE-MINDIFF);
POSITION := 0 ;
TURTLEUNITS := 0 ;
END//建立多头止损条件
LONGX2 := (LOW<MYE***YPRICE-2*N) ;IF LONGX2 AND POSITION=1 AND BUYORDERTHISBAR=0 THEN BEGIN
MYEXITPRICE := IF(OPEN<MYE***YPRICE-2*N ,OPEN ,MYE***YPRICE-2*N ) ;
MYEXITPRICE := FLOOR(MYEXITPRICE/MINDIFF)*MINDIFF ;
//SELL( _DEBUG ,0,LIMITR,MYEXITPRICE);
POSITION := 0 ;
TURTLEUNITS := 0 ;
ENDGOTO CONTINUELINE ;
END //IF
//如果当前持有空头仓位的状态IF POSITION = -1 AND BARPOS>T20 AND H>L THEN BEGIN
//空头加仓条件
WHILE (LOW<MYE***YPRICE-0.5*N) AND TURTLEUNITS<4 DO BEGIN
MYE***YPRICE := IF(OPEN<MYE***YPRICE-0.5*N ,OPEN ,MYE***YPRICE-0.5*N ) ;
MYE***YPRICE := FLOOR(MYE***YPRICE/MINDIFF)*MINDIFF ;
//BUYSHORT( _DEBUG,POSNUM, LIMITR, MYE***YPRICE);
TURTLEUNITS := TURTLEUNITS+1 ;
BUYORDERTHISBAR := 1;
END //IF
//建立空头离场条件
SHORTX1 := H > T10HI ;IF SHORTX1 AND BUYORDERTHISBAR=0 THEN BEGIN
MYEXITPRICE := IF(OPEN>T10HI+MINDIFF ,OPEN ,T10HI+MINDIFF ) ;
//SELLSHORT( _DEBUG,0,LIMITR,MYEXITPRICE+MINDIFF);
POSITION := 0 ;
TURTLEUNITS := 0 ;
END//建立空头止损条件
SHORTX2 := HIGH > MYE***YPRICE + 2*N ;IF SHORTX2 AND POSITION = -1 AND BUYORDERTHISBAR=0 THEN BEGIN
MYEXITPRICE := IF(OPEN>MYE***YPRICE+2*N ,OPEN ,MYE***YPRICE+2*N ) ;
MYEXITPRICE := CEILING(MYEXITPRICE/MINDIFF)*MINDIFF ;
//SELLSHORT( _DEBUG,0,LIMITR,MYEXITPRICE);
POSITION := 0 ;
TURTLEUNITS := 0 ;
ENDEND //IF
//显示账户状态
CONTINUELINE@ 资产:TASSET,LINETHICK0;
//可用现金:CASH(0),LINETHICK0;
POS:THOLDING,LINETHICK0;
//交易次数:TOTALDAYTRADE, LINETHICK0 ;
//EP:MYE***YPRICE ;
// DEBUGOUT('POSITION=%.0F' ,POSITION ) ;
// DEBUGOUT('TURTLEUNITS=%.0F' ,TURTLEUNITS ) ;
// DEBUGOUT('BARPOS=%.0F' ,BARPOS ) ;
// DEBUGOUT('MYE***YPRICE=%.0F' ,MYE***YPRICE ) ;IF _DEBUGOUT>0 AND ISLASTBAR THEN BEGIN
DEBUGFILE2('C:\DEBUGFILE.TXT','BARPOS=%.0F' ,BARPOS,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','T20HI=%.2F' ,T20HI ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','N=%.2F' ,N ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','***GTR=%.2F' ,***GTR ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','POSITION=%.0F' ,POSITION,1 ) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','TURTLEUNITS=%.0F' ,TURTLEUNITS,1 ) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','OPEN=%.2F' ,O ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','HIGH=%.2F' ,H ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','LOW=%.2F' ,L ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','CLOSE=%.2F' ,C ,1) ;
DEBUGFILE2('C:\DEBUGFILE.TXT','MYE***YPRICE=%.0F' ,MYE***YPRICE ,1) ;END //IF
有思路,想编写各种指标公式,交易模型,选股公式,还原公式的朋友
可联系技术人员 QQ: 262069696 或微信号:cxh99cxh99 进行 有偿收费 编写!
(注:由于人数限制,QQ或微信请选择方便的一个联系我们就行,加好友时请简单备注下您的需求,否则无法通过。谢谢您!)
相关文章
-
没有相关内容