请选择 进入手机版 | 继续访问电脑版

比特币测试汇总

[复制链接]
查看74 | 回复3 | Brad | 2020-7-9 16:49:44 | 显示全部楼层 |阅读模式
比特币测试汇总:

【回测软件】文华财经
【回测品种】比特币主
【回测仓位】40%
【回测时间】20171218-20200708
【回测参数设置】

比特币回测参数设置.png


-----------------------------------------------------------------------------------------------------------------------

模型一:MACD带-盈67


MACD带-盈67总表.png

日线

MACD带-盈67-日线.png

小时线

MACD带-盈67-小时线.png

30M

MACD带-盈67-30M.png

15M

MACD带-盈67-15M.png

5M

MACD带-盈67-5M.png


【代码】:


//MACD带-盈67

//一、定义仓位
FUND:=10000000; //资金
TC:=INTPART(FUND*0.4/(C*MARGIN*UNIT+FEE));//计算开仓手数
TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//求最高价减去最低价,一个周期前的收盘价减去最高价的绝对值,一个周期前的收盘价减去最低价的绝对值,这三个值中的最大值
ATR : MA(TR,26);//求N个周期内的TR的简单移动平均

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA  : EMA(DIFF,9);//DIFF的M个周期指数平滑移动平均
MACD:2*(DIFF-DEA),COLORSTICK;//DIFF减DEA的2倍画柱状线

MACDV:=MACD>REF(MACD,1) AND REF(MACD,2)>REF(MACD,1);
MACDA:=MACD<REF(MACD,1) AND REF(MACD,2)<REF(MACD,1);

//////////////////////////////////////////////

LEN:CONDBARS(CROSSUP(DIFF,DEA),CROSSDOWN(DIFF,DEA));//最近一次满足DIFF上穿DEA与DIFF下穿DEA之间的周期数

//描述MACD之鱼【带鱼都是盈利的,短鱼都是亏损的】
//1、带鱼
DDAI:=C>REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //当前死叉,前一次金叉,多带鱼
KDAI:=C<REF(C,LEN) AND CROSSUP(DIFF,DEA); //当前金叉,前一次死叉,空带鱼

//2、短鱼
DDUAN:=C<REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //当前死叉,前一次金叉,多短鱼
KDUAN:=C>REF(C,LEN) AND CROSSUP(DIFF,DEA); //当前金叉,前一次死叉,空短鱼

DRAWTEXT(DDAI ,H ,'多带'),VALIGN2,FONTSIZE18,COLORWHITE;
DRAWTEXT(DDUAN ,H ,'多短'),VALIGN2,FONTSIZE18,COLORWHITE;
DRAWTEXT(KDAI ,L,'空带'),VALIGN2,FONTSIZE18,COLORWHITE;
DRAWTEXT(KDUAN ,L ,'空短'),VALIGN2,FONTSIZE18,COLORWHITE;

//记录带鱼的次数
DDAICS:=-1*COUNT(DDAI,0);//多带鱼次数

//带鱼的方向
DDK : IF(BARSLAST(DDAI )<BARSLAST(KDAI), 1, -1);

///////////////////////////////////////////////////////////////

CROSS(DIFF,DEA) AND ( DDK=1), BPK(TC);//
CROSSDOWN(DIFF,DEA) AND (DDK=-1) , SPK(TC);//
CROSS(DIFF,DEA) AND  (DDK=-1), BP(SKVOL);//
CROSSDOWN(DIFF,DEA) AND ( DDK=1), SP(BKVOL);//

回复

使用道具 举报

Brad | 2020-7-9 16:57:28 | 显示全部楼层
模型二:MACD带-VA鱼1_DDKVA过滤

MACD带-VA鱼1_DDKVA过滤日线总表.png


日线

MACD带-VA鱼1_DDKVA过滤日线.png

1H

MACD带-VA鱼1_DDKVA过滤1H.png

30M

MACD带-VA鱼1_DDKVA过滤30M.png

15M

MACD带-VA鱼1_DDKVA过滤15M.png

5M

MACD带-VA鱼1_DDKVA过滤5M.png

【代码】(N=26)

//MACD带-VA鱼1_DDKVA过滤
//一、定义仓位
FUND:=10000000;
TC:=INTPART(FUND*0.4/(C*MARGIN*UNIT+FEE));
TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : MA(TR,N);

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA  : EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
LEN:CONDBARS(CROSSUP(DIFF,DEA),CROSSDOWN(DIFF,DEA));

//定义MACD柱VA鱼
MACDV:=MACD>REF(MACD,1) AND REF(MACD,2)>REF(MACD,1);
MACDA:=MACD<REF(MACD,1) AND REF(MACD,2)<REF(MACD,1);
DYT:=MACDV;
KYT:=MACDA;
FBPK := DYT AND COUNT(DYT, BARSLAST(KYT))=1;
FSPK := KYT AND COUNT(KYT, BARSLAST(DYT))=1;
BPKC := IF(FBPK , C, REF(C, BARSLAST(FBPK)));
SPKC := IF(FSPK , C, REF(C, BARSLAST(FSPK)));
LENVA := CONDBARS(FBPK, FSPK);

//MACD带鱼短鱼
DDAI:=C>REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //MACD多带鱼
KDAI:=C<REF(C,LEN) AND CROSSUP(DIFF,DEA); //MACD空带鱼
DDUAN:=C<REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //MACD空带鱼
KDUAN:=C>REF(C,LEN) AND CROSSUP(DIFF,DEA); //MACD空短鱼

//MACDVA带鱼短鱼
DDAIVA := C>REF(C,LENVA) AND FSPK;
KDAIVA := C<REF(C,LENVA) AND FBPK;
DDUANVA := C<=REF(C,LENVA) AND FSPK;
KDUANVA := C>=REF(C,LENVA) AND FBPK;

//带鱼的次数
DDAICS:=-1*COUNT(DDAI,0);//多带次数
KDAICS:=-1*COUNT(KDAI,0);//空带次数
DDUANCS:=COUNT(DDUAN ,0);//多短次数
KDUANCS:=COUNT(KDUAN ,0);//空短次数
DAIYUCS:=DDAICS+KDAICS;//总带次数
DUANYUCS:=DDUANCS+KDUANCS;//总短次数
DDAICSVA := -1*COUNT(DDAIVA,0);//MACDVA
DKDUANYUCS:=IF(ABS(DAIYUCS)>REF(ABS(DAIYUCS),1), DUANYUCS, REF(DUANYUCS, BARSLAST((KDAI OR DDAI))));
DKDAIYUCS:=IF(ABS(DUANYUCS)>REF(ABS(DUANYUCS),1), DAIYUCS, REF(DAIYUCS, BARSLAST((DDUAN OR KDUAN))));

//带鱼的方向
DDK : IF(BARSLAST(DDAI)<BARSLAST(KDAI), 1, -1);
DDKVA : IF(BARSLAST(DDAIVA)<BARSLAST(KDAIVA), 1, -1);

//MACD标记
//DRAWTEXT(DDAI ,H+0.8 ,'多带'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(DDUAN ,H+0.8 ,'多短'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDAI ,L-0.8,'空带'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDUAN ,L-0.8,'空短'),VALIGN0,FONTSIZE18,COLORWHITE;
DRAWTEXT(DDAIVA ,H+0.5 ,'VA多带'),VALIGN2,FONTSIZE14,COLORRED;
DRAWTEXT(DDUANVA ,H+0.5 ,'VA多短'),VALIGN2,FONTSIZE14,COLORRED;
DRAWTEXT(KDAIVA ,L-0.5,'VA空带'),VALIGN2,FONTSIZE14,COLORGREEN;
DRAWTEXT(KDUANVA ,L-0.5 ,'VA空短'),VALIGN2,FONTSIZE14,COLORGREEN;

//VATJ
VATJ:IF(MOD(ABS(DUANYUCS-DKDUANYUCS),2)=0,1,0);//判断带鱼奇偶

//MACD交易指令
MACDBK:=IF(VATJ=0 AND DDK=1 AND BKVOL=0, 1,0);
MACDSK:=IF(VATJ=0 AND (DDK=-1) AND SKVOL=0,-1,0);
MACDXH : MACDBK+MACDSK;

MACDBK=1, BPK(TC);
MACDSK=-1, SPK(TC);
CROSS(DIFF,DEA) AND (DDK=-1), BP(SKVOL);
CROSSDOWN(DIFF,DEA) AND (DDK=1), SP(BKVOL);

//MACDVA交易指令
VABK:IF(FBPK AND DDK=1 AND BKVOL=0,1,0);
VASK:IF(FSPK AND DDK=-1 AND SKVOL=0,-1,0);
VAXH:= VABK+VASK;

FBPK AND DDKVA=1 AND VATJ=1 AND BKVOL=0, BPK(TC);//AND DDKVA=1
FSPK AND DDKVA=-1 AND VATJ=1 AND SKVOL=0, SPK(TC);//AND DDKVA=-1
DYT AND SKVOL>0 AND VATJ=1, BP(SKVOL);//
KYT AND BKVOL>0 AND VATJ=1, SP(BKVOL);//

回复

使用道具 举报

Brad | 2020-7-9 17:08:01 | 显示全部楼层

模型三:MACD带-VA鱼2_双过滤

MACD带-VA鱼2_双过滤总表.png


日线

MACD带-VA鱼2_双过滤日线.png

1H

MACD带-VA鱼2_双过滤1H.png

30M

MACD带-VA鱼2_双过滤30M.png

15M

MACD带-VA鱼2_双过滤15M.png

5M

MACD带-VA鱼2_双过滤5M.png


【代码】(N=26)
//MACD带-VA鱼2_双过滤日线
//一、定义仓位
FUND:=10000000;
TC:=INTPART(FUND*0.4/(C*MARGIN*UNIT+FEE));
TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : MA(TR,N);

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA  : EMA(DIFF,9);
MACD:2*(DIFF-DEA),COLORSTICK;
LEN:CONDBARS(CROSSUP(DIFF,DEA),CROSSDOWN(DIFF,DEA));

//定义MACD柱VA鱼
MACDV:=MACD>REF(MACD,1) AND REF(MACD,2)>REF(MACD,1);
MACDA:=MACD<REF(MACD,1) AND REF(MACD,2)<REF(MACD,1);
DYT:=MACDV;
KYT:=MACDA;
FBPK := DYT AND COUNT(DYT, BARSLAST(KYT))=1;
FSPK := KYT AND COUNT(KYT, BARSLAST(DYT))=1;
BPKC := IF(FBPK , C, REF(C, BARSLAST(FBPK)));
SPKC := IF(FSPK , C, REF(C, BARSLAST(FSPK)));
LENVA := CONDBARS(FBPK, FSPK);

//MACD带鱼短鱼
DDAI:=C>REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //MACD多带鱼
KDAI:=C<REF(C,LEN) AND CROSSUP(DIFF,DEA); //MACD空带鱼
DDUAN:=C<REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //MACD空带鱼
KDUAN:=C>REF(C,LEN) AND CROSSUP(DIFF,DEA); //MACD空短鱼

//MACDVA带鱼短鱼
DDAIVA := C>REF(C,LENVA) AND FSPK;
KDAIVA := C<REF(C,LENVA) AND FBPK;
DDUANVA := C<=REF(C,LENVA) AND FSPK;
KDUANVA := C>=REF(C,LENVA) AND FBPK;

//带鱼的次数
DDAICS:=-1*COUNT(DDAI,0);//多带次数
KDAICS:=-1*COUNT(KDAI,0);//空带次数
DDUANCS:=COUNT(DDUAN ,0);//多短次数
KDUANCS:=COUNT(KDUAN ,0);//空短次数
DAIYUCS:=DDAICS+KDAICS;//总带次数
DUANYUCS:=DDUANCS+KDUANCS;//总短次数
DDAICSVA := -1*COUNT(DDAIVA,0);//MACDVA
DKDUANYUCS:=IF(ABS(DAIYUCS)>REF(ABS(DAIYUCS),1), DUANYUCS, REF(DUANYUCS, BARSLAST((KDAI OR DDAI))));
DKDAIYUCS:=IF(ABS(DUANYUCS)>REF(ABS(DUANYUCS),1), DAIYUCS, REF(DAIYUCS, BARSLAST((DDUAN OR KDUAN))));

//带鱼的方向
DDK : IF(BARSLAST(DDAI)<BARSLAST(KDAI), 1, -1);
DDKVA : IF(BARSLAST(DDAIVA)<BARSLAST(KDAIVA), 1, -1);

//MACD标记
//DRAWTEXT(DDAI ,H+0.8 ,'多带'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(DDUAN ,H+0.8 ,'多短'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDAI ,L-0.8,'空带'),VALIGN0,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDUAN ,L-0.8,'空短'),VALIGN0,FONTSIZE18,COLORWHITE;
DRAWTEXT(DDAIVA ,H+0.5 ,'VA多带'),VALIGN2,FONTSIZE14,COLORRED;
DRAWTEXT(DDUANVA ,H+0.5 ,'VA多短'),VALIGN2,FONTSIZE14,COLORRED;
DRAWTEXT(KDAIVA ,L-0.5,'VA空带'),VALIGN2,FONTSIZE14,COLORGREEN;
DRAWTEXT(KDUANVA ,L-0.5 ,'VA空短'),VALIGN2,FONTSIZE14,COLORGREEN;

//VATJ
VATJ:IF(MOD(ABS(DUANYUCS-DKDUANYUCS),2)=0,1,0);//判断带鱼奇偶

//MACD交易指令
MACDBK:=IF(VATJ=0 AND DDK=1 AND BKVOL=0, 1,0);
MACDSK:=IF(VATJ=0 AND (DDK=-1) AND SKVOL=0,-1,0);
MACDXH : MACDBK+MACDSK;

MACDBK=1, BPK(TC);
MACDSK=-1, SPK(TC);
CROSS(DIFF,DEA) AND (DDK=-1), BP(SKVOL);
CROSSDOWN(DIFF,DEA) AND (DDK=1), SP(BKVOL);

//MACDVA交易指令
VABK:IF(FBPK AND DDK=1 AND BKVOL=0,1,0);
VASK:IF(FSPK AND DDK=-1 AND SKVOL=0,-1,0);
VAXH:= VABK+VASK;

FBPK AND DDKVA=1 AND DDK=1 AND VATJ=1 AND BKVOL=0, BPK(TC);//AND DDKVA=1
FSPK AND DDKVA=-1 AND DDK=-1 AND VATJ=1 AND SKVOL=0, SPK(TC);//AND DDKVA=-1
DYT AND SKVOL>0 AND VATJ=1, BP(SKVOL);//
KYT AND BKVOL>0 AND VATJ=1, SP(BKVOL);//

回复

使用道具 举报

Brad | 2020-7-10 19:27:31 | 显示全部楼层
【回测时间】20180101-20200708
【初始资金】10个BTC
【回测仓位】40%
【回测平台】发明者
【手续费】0.075%
MACD带-盈67-总表.png

1H
MACD带-盈67-1小时+手续费.png

2H
MACD带-盈67-2小时+手续费.png

4H
MACD带-盈67-4小时+手续费.png

【代码(发明者)】

TC:=C*10*0.4;
TR : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));//求最高价减去最低价,一个周期前的收盘价减去最高价的绝对值,一个周期前的收盘价减去最低价的绝对值,这三个值中的最大值
ATR : MA(TR,26);//求N个周期内的TR的简单移动平均


DIFF : EMA(CLOSE,12) - EMA(CLOSE,26);//短周期与长周期的收盘价的指数平滑移动平均值做差。
DEA  : EMA(DIFF,9);//DIFF的M个周期指数平滑移动平均
MACD:2*(DIFF-DEA),COLORSTICK;//DIFF减DEA的2倍画柱状线

MACDV:=MACD>REF(MACD,1) AND REF(MACD,2)>REF(MACD,1);
MACDA:=MACD<REF(MACD,1) AND REF(MACD,2)<REF(MACD,1);

//////////////////////////////////////////////

LEN:CONDBARS(CROSSUP(DIFF,DEA),CROSSDOWN(DIFF,DEA));//最近一次满足DIFF上穿DEA与DIFF下穿DEA之间的周期数

//描述MACD之鱼【带鱼都是盈利的,短鱼都是亏损的】
//1、带鱼
DDAI:=C>REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //当前死叉,前一次金叉,多带鱼
KDAI:=C<REF(C,LEN) AND CROSSUP(DIFF,DEA); //当前金叉,前一次死叉,空带鱼

//2、短鱼
DDUAN:=C<REF(C,LEN) AND CROSSDOWN(DIFF,DEA); //当前死叉,前一次金叉,多短鱼
KDUAN:=C>REF(C,LEN) AND CROSSUP(DIFF,DEA); //当前金叉,前一次死叉,空短鱼

//DRAWTEXT(DDAI ,H ,'多带'),VALIGN2,FONTSIZE18,COLORWHITE;
//DRAWTEXT(DDUAN ,H ,'多短'),VALIGN2,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDAI ,L,'空带'),VALIGN2,FONTSIZE18,COLORWHITE;
//DRAWTEXT(KDUAN ,L ,'空短'),VALIGN2,FONTSIZE18,COLORWHITE;

//记录带鱼的次数
DDAICS:=-1*COUNT(DDAI,0);//多带鱼次数

//带鱼的方向
DDK : IF(BARSLAST(DDAI )<BARSLAST(KDAI), 1, -1);

///////////////////////////////////////////////////////////////
//DRAWTEXT(TC, C, "TC");
CROSS(DIFF,DEA) AND ( DDK=1), BPK(TC);//
CROSSDOWN(DIFF,DEA) AND (DDK=-1) , SPK(TC);//
CROSS(DIFF,DEA) AND  (DDK=-1), BP(SKVOL);//
CROSSDOWN(DIFF,DEA) AND ( DDK=1), SP(BKVOL);//


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关课程推荐
桥博士《MACD指标详解》
为什么我们只用MACD金叉死叉来进行操作效果并不好,学习课程就能在研究MACD指标上少走很多弯路
桥博士《K线形态组合解析》
从理论到实战,让您全面掌握各种K线形态及各种组合,帮您分析梳理大量K线知识让您的投资更游刃有余
桥博士《股票入门基础知识》
从理论到实战,课程包括如何买卖股票、开户流程、交易软件、k线图知识、技术指标、价值投资等新手必备知识

68

主题

255

帖子

738

积分

高级会员

Rank: 4

积分
738
  • 官方论坛

    提供最新 Discuz! 产品新闻、软件下载与技术交流