请帮助改写成金字塔图表程序化代码,谢谢
N1:=BARSLAST(DATE<>REF(DATE,1))+1;
N:=A01;//A01,自己编写填入
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//真实波幅
ATR:=MA(TR,30); //求26个周期内真实波幅的简单移动平均
MATR:=A02/;/自己编写填入
DIFF:EMA(CLOSE,3*N)-EMA(CLOSE,6*N);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA:EMA(DIFF,2*N);//DIFF的M个周期指数平滑移动平均
MACD:2*(DIFF-DEA),COLORSTICK;//DIFF减DEA的2倍画柱状线
MAH:A03;//自己编写填入
MAC:A04;//自己编写填入
HH:=A05;//自己编写填入
LL:=A06;//自己编写
BSK:A07;//自己编写填入
M11:A08;//自己编写填入
M22:A09;//自己编写填入
GGLL:=ABS(M11-M22)/MA22*1000;
HLGL:=MA(GGLL,2000);
HLGLP:=5*HLGL;
C>(MAH*1.002)&&MAH>REF(MAH,1)&&C>HH&&C<MA22*1.08,BK(K);//
C<(MAL*0.998)&&MAL<REF(MAL,1)&&C<LL&&C>MA22*0.92,SK(K);//
C<REF(LLV(C,10),BARSBK)-2*ATR,SP(BKVOL);//开仓K线前10个周期收盘价的最低价-2*ATR止损;
C>REF(HHV(C,10),BARSSK)+2*ATR,BP(SKVOL);//开仓K线前10个周期收盘价的最高价+2*ATR止损
C>SKLOW*1.055,BP(SKVOL);//固定回撤平空单
C<BKHIGH*0.945,SP(BKVOL);//固定回撤平多单
GGLLL>HLGLP,CLOSEOUT;//率过大平仓
C<BKPRICE-3*ATR,SP(BKVOL);
C>SKPRICE+3*ATR,BP(SKVOL);
CROSSDOWN(MA11,MA22)||C<MAL,SP(BKVOL);
CROSSUP(MA11,MA22)||C>MAH,BP(SKVOL);
//MID<REF(MID,60),SP(BKVOL);
//MID>REF(MID,60),BP(SKVOL);
BKHIGH>MA22*1.08&&C<BKHIGH-3*ATR,SP(BKVOL);//
SKLOW<MA22*0.92&&C>SKLOW+3*ATR,BP(SKVOL);//止盈;
BKHIGH>MAC*1.08&&C<BKHIGH-6*ATR,SP(BKVOL);//
SKLOW<MAC*0.92&&C>SKLOW+6*ATR,BP(SKVOL);//止盈;
COUNT(ATR>MATR*1.7,10)>=3&&C<LV(C,30),SP(BKVOL);//
COUNT(ATR>MATR*1.7,10)>=3&&C>HV(C,30),BP(SKVOL);//出场;
BKHIGH- BKPRICE>C/70 && (C-BKPRICE)/(BKHIGH-BKPRICE)<=0.2,SP(BKVOL);
SKPRICE-SKLOW>C/70 &&(SKPRICE-C)/(SKPRICE-SKLOW)<=0.2,BP(SKVOL);//止盈平仓
CLOSEKLINE(2,10);
TRADE_AGAIN(10);
把交易的部分换下试下。
if C>(MAH*1.002) and MAH>REF(MAH,1) and C>HH and C<MA22*1.08 then buy(holding=0,k,market);
if C<(MAL*0.998) and MAL<REF(MAL,1) and C<LL and C>MA22*0.92 then buyshort(holding=0,k,market);
if C<REF(LLV(C,10),ENTERBARS+2)-2*ATR then sell(1,holding,market);//开仓K线前10个周期收盘价的最低价-2*ATR止损;
if C>REF(HHV(C,10),ENTERBARS+2)+2*ATR then sellshort(1,holding,market);//开仓K线前10个周期收盘价的最高价+2*ATR止损
if C>llv(l,ENTERBARS+1)*1.055 then sellshort(1,holding,market);//固定回撤平空单
if C<hhv(h,ENTERBARS+1)*0.945 then sell(1,holding,market);//固定回撤平多单
if GGLLL>HLGLP then
begin
sell(1,holding,market);
sellshort(1,holding,market);
end
if C<ENTERPRICE-3*ATR then sell(1,holding,market);
if C>ENTERPRICE+3*ATR then sellshort(1,holding,market);
if CROSS(MA22,MA11) or C<MAL then sell(1,holding,market);
if CROSS(MA11,MA22)or C>MAH then sellshort(1,holding,market);
//MID<REF(MID,60),SP(BKVOL);
//MID>REF(MID,60),BP(SKVOL);
if hhv(h,ENTERBARS+1)>MA22*1.08 and C<hhv(h,ENTERBARS+1)-3*ATR then sell(1,holding,market);
if llv(l,ENTERBARS+1)<MA22*0.92 and C>llv(l,ENTERBARS+1)+3*ATR then sellshort(1,holding,market);
if hhv(h,ENTERBARS+1)>MAC*1.08 and C< hhv(h,ENTERBARS+1)-6*ATR then sell(1,holding,market);
if llv(l,ENTERBARS+1)<MAC*0.92 and C>llv(l,ENTERBARS+1)+6*ATR then sellshort(1,holding,market);
if COUNT(ATR>MATR*1.7,10)>=3 and C<LV(C,30) then sell(1,holding,market);
if COUNT(ATR>MATR*1.7,10)>=3 and C>HV(C,30) then sellshort(1,holding,market);
if hhv(h,ENTERBARS+1)- ENTERPRICE>C/70 and (C-ENTERPRICE)/(hhv(h,ENTERBARS+1)-ENTERPRICE)<=0.2 then sell(1,holding,market);
if ENTERPRICE-llv(l,ENTERBARS+1)>C/70 and (ENTERPRICE-C)/(ENTERPRICE-llv(l,ENTERBARS+1))<=0.2 then sellshort(1,holding,market);
//CLOSEKLINE(2,10);
CLOSEKLINE 这个我们无法实现。没办法做这个信号复核的。
“MAH:A03;//自己编写填入”这个是参数还是只是未完成的部分?
最好能补全下,这样我改好了能简单测试下。