老师求把以外文华海龟改成金字塔的,一根k只能有一个信号,收盘价模型,要是跟我在文化信号一样我就在金字塔做了!
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//真实波幅 ATR:=MA(TR,26); //求26个周期内真实波幅的简单移动平均 TC..INTPART((MONEYTOT*0.01/(UNIT*ATR)));//根据权益的1%计算下单手数 MTC..4*TC; //总的持仓头寸 HH:=HV(H,20); LL:=LV(L,20); CROSSUP(C,HH)&&ISLASTBK=0&&ISLASTSK=0&&BARPOS>=26,BK(TC);//最新价超过20周期的最高值,首次买入开仓,手数为TC手 CROSSDOWN(C,LL)&&ISLASTBK=0&&ISLASTSK=0,SK(TC); //最新价跌破20周期的最低值,首次卖出开仓,手数为TC手 C>=BKPRICE+0.5*ATR&&BKVOL<MTC&&ISLASTBK,BK(TC);//价格在上次开仓的基础上上涨0.5倍ATR,在手数不超过4倍TC的时候,买入加仓TC手 C<=SKPRICE-0.5*ATR&&SKVOL<MTC&&ISLASTSK,SK(TC);//价格在上次开仓的基础上下跌0.5倍ATR,在手数不超过4倍TC的时候,卖出加仓TC手 C<=(BKPRICE-2*ATR)&&BKVOL>0,SP(BKVOL);//最新价小于开仓价减去2倍的ATR,止损平仓 C>=(SKPRICE+2*ATR)&&SKVOL>0,BP(SKVOL); //最新价大于开仓价加上2倍的ATR,止损平仓 CROSSUP(H,HV(H,10))&&SKVOL>0,BP(SKVOL);//最高价上穿10周期最高价,平仓 CROSSDOWN(L,LV(L,10))&&BKVOL>0,SP(BKVOL); //最低价下穿10周期的最低价,平仓 TRADE_AGAIN(10);
麻烦把代码按行复制下来,你这样搞,注释和代码混杂在一起。我分不清的。
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR,26);
TC..INTPART((MONEYTOT*0.01/(UNIT*ATR)));
MTC..4*TC;
HH:=HV(H,20);
LL:=LV(L,20);
CROSSUP(C,HH)&&ISLASTBK=0&&ISLASTSK=0&&BARPOS>=26,BK(TC);
CROSSDOWN(C,LL)&&ISLASTBK=0&&ISLASTSK=0,SK(TC);
C>=BKPRICE+0.5*ATR&&BKVOL<MTC&&ISLASTBK,BK(TC);
C<=SKPRICE-0.5*ATR&&SKVOL<MTC&&ISLASTSK,SK(TC);
C<=(BKPRICE-2*ATR)&&BKVOL>0,SP(BKVOL);
C>=(SKPRICE+2*ATR)&&SKVOL>0,BP(SKVOL);
CROSSUP(H,HV(H,10))&&SKVOL>0,BP(SKVOL);
CROSSDOWN(L,LV(L,10))&&BKVOL>0,SP(BKVOL);
TRADE_AGAIN(10);
TRX:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TRX,26);
TC:=INTPART((ASSET*0.01/(MULTIPLIER*ATR)));
MTC:=4*TC;
HH:=REF(HHV(H,20),1);
LL:=ref(LlV(L,20),1);
IF CROSS(C,HH) and holding=0 and BARPOS>=26 THEN BUY(1,tc,market);
if CROSS(LL,C) AND holding=0 then buyshort(1,TC,market);
if C>=ENTERPRICE+0.5*ATR AND ABS(holding)<MTC AND holding>0 then BUY(1,tc,market);
IF C<=ENTERPRICE-0.5*ATR AND ABS(holding) AND holding<0 then buyshort(1,TC,market);
IF C<=(ENTERPRICE-2*ATR) AND HOLDING>0 THEN SELL(1,HOLDING,MARKET);
IF C>=(ENTERPRICE+2*ATR) AND HOLDING<0 THEN SELLSHORT(1,HOLDING,MARKET);
IF CROSS(H,REF(HHV(H,10),1)) AND HOLDING<0 THEN SELLSHORT(1,HOLDING,MARKET);
IF CROSS(LLV(L,10),L) AND HOLDING>0 THEN SELL(1,HOLDING,MARKET);
截个图我看下。
贴图教程: http://www.weistock.com/bbs/dispbbs.asp?boardid=2&Id=31614