等级: 专业版
- 注册:
- 2022-1-11
- 曾用名:
|
请老师帮忙分析下策略执行中出现问题?
主要问题:1.加仓时策略与实际不相同?
2.止损时止多、止空条件成立,亏损额达到设定值不执行止损?
谢谢老师指教!
LM:MA(C,3),LINEDOT;
浮动盈亏:TACCOUNT( 4);
买入均价:=ENTERPRICE;
持仓量:HOLDING;
LM1:=LM>REF(LM,1) and REF(LM,1)<REF(LM,2);
LM2:=LM<REF(LM,1) and REF(LM,1)>REF(LM,2);
LM1A:=LM>REF(LM,1) and REF(LM,1)<REF(LM,2)
or LM>REF(LM,1) and REF(LM,1)>REF(LM,2) and REF(LM,2)<REF(LM,3);
LM2A:=LM<REF(LM,1) and REF(LM,1)>REF(LM,2)
or LM<REF(LM,1) and REF(LM,1)<REF(LM,2) and REF(LM,2)>REF(LM,3) ;
N1:=(BARSLAST(LM1)+1);
N2:=(BARSLAST(LM2)+1);
LM11:=REF(C,N1);
LM12:=REF(C,N2);
LM3:LM11-LM12;
LM4:IF(LM>REF(LM,1),(C-LM11),IF(LM<REF(LM,1),(C-LM12),''));
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
波动:=MA(TR1,20);
波幅:INTPART(波动)*MINDIFF;
A波1:= ABS(LM3)>5*MINDIFF;
A波2:= ABS(LM3)>6*MINDIFF;
AA1:= {A波1=1 and} LM1A=1; //平空
AA2:= {A波1=1 and} HOLDING=0 and LM1=1; //开多1
AA21:= HOLDING>0 and ABS(LM3)>2*波幅 and LM1=1 ; //开多2
AA3:= {A波1=1 and} LM2A=1;//平多
AA4:= {A波1=1 and} HOLDING=0 and LM2=1 ;//开空1
AA41:= HOLDING<0 and ABS(LM3)>2*波幅 and LM2=1 ;//开空2
AA5:= LM<REF(LM,1) and 浮动盈亏<-300 ; //止多
AA6:= LM>REF(LM,1) and 浮动盈亏<-300; //止空
DRAWTEXT(LM1=1,H-6,'买'),COLORGREEN;
DRAWTEXT(LM2=1,L+6,'卖'),COLORRED;
DRAWTEXTEX(AA1=1,0,670,0,'平空');
DRAWTEXTEX(AA2=1,0,700,0,'开多1');
DRAWTEXTEX(AA21=1,0,700,0,'开多2');
DRAWTEXTEX(AA3=1,0,730,0,'平多');
DRAWTEXTEX(AA4=1,0,760,0,'开空1');
DRAWTEXTEX(AA41=1,0,760,0,'开空2');
DRAWTEXTEX(AA5=1,0,630,0,'止多');
DRAWTEXTEX(AA6=1,0,630,0,'止空');
IF AA1=1 THEN //且满足平空条件
SELLSHORT(1,0,MARKETR,C); //平空单
IF AA2=1 THEN //且满足开多1条件
BUY(1,1,MARKETR,C); //开多1单
IF AA21=1 THEN //且满足开多2条件
BUY(1,1,MARKETR,C); //开多2单
IF AA5=1 THEN //且满足止多条件
SELL(1,0,MARKETR,C); //止多单
IF AA3=1 THEN//且满足平多条件
SELL(1,0,MARKETR,C); //平多单
IF AA4=1 THEN//且满足开空1条件
BUYSHORT(1,1,MARKETR,C); //开空1单
IF AA41=1 THEN//且满足开空2条件
BUYSHORT(1,1,MARKETR,C); //开空2单
IF AA6=1 THEN //且满足止空条件
SELLSHORT(1,0,MARKETR,C); //止空单
|
|