金字塔在信号闪烁问题上确实做的不够,除了小周期引用大周期导致的信号闪烁外,在同一根k线上进行平仓,金字塔也无法解决信号闪烁问题,比如这样一个例子,在开仓以后,模型计算一个止损值,当价格触碰这个值的时候立即止损平仓,那么在开仓的同一根K线上就必须要用到最新价c,用到c的话信号就会闪烁,我找了很多办法都无法固定dang根K线上的这个信号!
闪烁这种不是软件平台造成的,是你自己的策略处理上造成的。close本身就是变动的,要是不在信号触发点的位置闪动才是怪事,除非行情持续向一个方向上升或者下降。
这种是需要你自己条件中控制的。
闪烁这种不是软件平台造成的,是你自己的策略处理上造成的。close本身就是变动的,要是不在信号触发点的位置闪动才是怪事,除非行情持续向一个方向上升或者下降。
这种是需要你自己条件中控制的。
谢谢,我不是说闪烁是软件造成的,我的意思是金字塔在解决信号闪烁问题上做的不够,需要在同一根K线上做止损平仓,这个需求应该不少吧,如果不用close来处理这个止损条件,你有别的方法吗?用到close就一定会闪烁,我尝试了好多种办法都解决不了,包括不在同一根K线上止损,而是用软件的自动止损功能,但它的止损值是固定的,我需要动态计算这个止损值,所以替代不了!
你说是策略处理上造成的,没错,但我想在同一根K线上做止损平仓的需求,你有不用close信号不闪烁的处理方法吗?
这是公式代码,图表1分钟
input:ss(2,1,999,1),t(0,0,400000,1),p(0,0,400000,1);
VARIABLE:kzsATR=drawnull,doubleATR=drawnull,threeATR=drawnull,cfT=0,CFP=0,eckcON=0;//eckcON为二次开仓开关。
ATR:=ref(MA(tr,20),1);
abb:=(time0-timetot0(dynainfo(207))<=20) or not(islastbar);
mck:=(h-l)/ma(tr,20);
3G:=if(ref(holding,1)<0,hhv(ref(h,1),2),drawnull);
ll:if(cfT=0 and t<>0 and date[DATACOUNT]=date,t,drawnull),LINETHICK2,colorblue;
lll:if(cfP=0 and p<>0 and date[DATACOUNT]=date,p,drawnull),LINETHICK2,COLORBROWN;
///////////////////收盘和夜盘平仓模块//////////////////////////////////////////////////////////////////////////////
neipan:=STRNCMP(STKNAME,'螺纹',4)=0 or STRNCMP(STKNAME,'矿石',4)=0 or STRNCMP(STKNAME,'轧卷',4)=0 or
STRNCMP(STKNAME,'焦炭',4)=0 or STRNCMP(STKNAME,'焦煤',4)=0 or STRNCMP(STKNAME,'玻璃',4)=0 or
STRNCMP(STKNAME,'动力',4)=0 or STRNCMP(STKNAME,'鸡蛋',4)=0 or STRNCMP(STKNAME,'硅铁',4)=0 or
STRNCMP(STKNAME,'锰硅',4)=0 or STRNCMP(STKNAME,'橡胶',4)=0 or STRNCMP(STKNAME,'玉米',4)=0 or
STRNCMP(STKNAME,'淀粉',4)=0 ; //内盘品种
youse:=STRNCMP(STKNAME,'沪铜',4)=0 or STRNCMP(STKNAME,'沪锌',4)=0 or STRNCMP(STKNAME,'沪铝',4)=0 or
STRNCMP(STKNAME,'沪镍',4)=0 or STRNCMP(STKNAME,'沪锡',4)=0 or STRNCMP(STKNAME,'沪铅',4)=0 ;
guijin:=STRNCMP(STKNAME,'白银',4)=0 or STRNCMP(STKNAME,'黄金',4)=0;
huanggongnongchan:=STRNCMP(STKNAME,'沥青',4)=0 or STRNCMP(STKNAME,'豆一',4)=0 or
STRNCMP(STKNAME,'塑料',4)=0 or STRNCMP(STKNAME,'豆粕',4)=0 or STRNCMP(STKNAME,'棕榈',4)=0 or
STRNCMP(STKNAME,'聚氯',4)=0 or STRNCMP(STKNAME,'豆油',4)=0 or STRNCMP(STKNAME,'豆粕',4)=0 or
STRNCMP(STKNAME,'聚丙',4)=0 or STRNCMP(STKNAME,'棉花',4)=0 or STRNCMP(STKNAME,'新菜',4)=0 or
STRNCMP(STKNAME,'白糖',4)=0 or STRNCMP(STKNAME,'P',1)=0 or STRNCMP(STKNAME,'甲醇',4)=0 or
STRNCMP(STKNAME,'菜粕',4)=0 ;
IFclose:=if(time=190000 or (time=050000 and youse) or (time=063000 and guijin) or
(time=033000 and huanggongnongchan) or (time=030000 and strleft(stkname,4)='沥青'),1,0 );
if IFclose and abb and dynainfo(55)<>c and holding<0 then begin
sellshort(1,holding,marketr);
kzsATR:=drawnull;
doubleATR:=drawnull;
threeATR:=drawnull;
end
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//开空
if l<=ll then begin
if o>=ll and holding=0 and not(IFclose) then BEGIN
buyshort(1,ss,limitr,ll-mindiff*4);
kzsATR:=ll+max(mindiff*2,ATR);
doubleATR:=ll-ATR*2;
threeATR:=ll-ATR*3;
end
cfT:=1;
end
if l<=lll then begin
if o>=lll and holding=0 and eckcON=1 and not(IFclose) then BEGIN
buyshort(1,ss,limitr,lll-mindiff*4);
kzsATR:=lll+max(mindiff*2,ATR);
doubleATR:=lll-ATR*2;
threeATR:=lll-ATR*3;
cfP:=1;
end
if l<lll then cfP:=1;
end
//破3根K线最高价平仓
if holding<0 and h>3G then BEGIN
SELLSHORT(1,holding,marketr);
kzsATR:=drawnull;
doubleATR:=drawnull;
threeATR:=drawnull;
eckcON:=1;
end
//ATR止损
if holding<0 then begin
if l<doubleATR then kzsATR:=min(kzsATR,ENTERPRICE+mindiff*4);//突破2倍ATR后下移止损
if l<threeATR then kzsATR:=min(kzsATR,ENTERPRICE+mindiff*2);//突破3倍ATR后下移止损
end
CorH:=if(enterbars=0 or kzsATR<ref(kzsATR,1),c,h);
if CorH>kzsATR and holding<0 then BEGIn
SELLSHORT(1,holding,marketr);
kzsATR:=drawnull;
doubleATR:=drawnull;
threeATR:=drawnull;
eckcON:=1;
end
//脉冲大K线平仓
ccl:=openint<ref(openint,1);
if holding<0 and ccl and mck>5 and (c-l)>mindiff*2 then begin
sellshort(1,holding,marketr);
kzsATR:=drawnull;
doubleATR:=drawnull;
threeATR:=drawnull;
end
//日内全局变量归零处理
//if time=CLOSETIME(0) then eckcON:=0;
止损线:min(3G,kzsatr),colorred;
//调试
2atrr:doubleATR;
3atr:threeatr;
//qqqqq:EXTGBDATA('A1')
没办法,在图表中不能做到鱼和熊掌兼得的。你即需要即时止损触发,又需要图表中产生的信号稳定。
或者你考虑使用后台,后台没有闪烁的概念,触发就是触发,不会牵扯到历史k线信号虚拟的计算。