if cross(diff,dea) and barpos>35 and tbuyholding(1)=0 and TTOTALDAYTRADE<1 then tbuy(1,10000/close,mkt);
if CROSS(ref(macd,1),macd) and tbuyholding(0)>0 then tsell(1,0,mkt);
老师,我用上面金叉公式回测时,回测结果与K线图吻合,但我用macd值结束下降,掉头上升时(红柱变长或绿柱变短,是否可以理解为今日的macd值上穿前一日的)回测时,回测结果与K线图不吻合,代码如下,请问是不是算法有错误,也请老师测试一下。
if cross(macd,ref(macd,1)) and barpos>35 and tbuyholding(1)=0 and TTOTALDAYTRADE<1 then tbuy(1,10000/close,mkt);
if CROSS(ref(macd,1),macd) and tbuyholding(0)>0 then tsell(1,0,mkt);
macd的算法受ema函数的递归计算的影响。ema对数据敏感度较高。
并且,你后台策略条件,放到图表上去进行比较,本身就两种机制,起比较的意义不大。