input:initialstop(20,10,60,10);
input:breakvenstop(20,10,60,10);
input:trailingstop(30,10,60,10);
input:money(2,1,10,1);
variable:stopline:=0;
begin
//predayhigh:=callstock(stklabel,vthigh,6,-1);//昨高
//predaylow:=callstock(stklabel,vtlow,6,-1);//昨低
//predayopen:=callstock(stklabel,vtopen,6,0);//昨收
//上轨:昨高;
//下轨:昨低;
//手数:=SS;
dist1:=barslast(day <> ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayopen:= ref(open,dist1-1);
entrytime:=time>=0916000 and time<=144500;
exittime:time>=150000;
initialstopnum:=mindiff*initialstop;
breakvenstopnum:=mindiff*breakvenstop;
trailingstopnum:=mindiff*trailingstop;
marginratio:=18/100;
end
if holding=0 then begin
if predayopen<predayhigh and entrytime and high>=predayhigh+mindiff then
myentryprice:=max(open,predayhigh+mindiff);
mycash:=cash(0);
lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
lots:=min(lots1,lots2);
buy(1,lots,limitr,myentryprice);
stopline:=0;
end
if holding=0 then begin
if predayopen>predaylow and entrytime and low<=predaylow - mindiff then
myentryprice:=max(open,predayhigh-mindiff);
mycash:=cash(0);
lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
lots:=min(lots1,lots2);
BUYSHORT(1,lots,limitr,myentryprice);
stopline:=0;
end
if holding>0 then begin
costprice:=enterprice+mindiff;
if exittime then
sell(1,holding,limitr,open);
end
if stopline>0 and low<=stopline then
sell(1,holding,limitr,min(open,stopline));
if stopline=0 then begin
stopline:=enterprice-initialstopnum;
if stopline<costprice and high- breakvenstopnum>=costprice then
stopline:=costprice;
if stopline>=costprice and high-trailingstopnum>=stopline then
stopline:=high-trailingstopnum;
end
if holding<0 then begin
costprice:=enterprice-mindiff;
if exittime then
sellshort(1,holding,limitr,open);
if stopline>0 and high>=stopline then
sellshort(1,holding,limitr,max(open,stopline));
if stopline=0 then
stopline:=enterprice+initialstopnum;
if stopline>costprice and low+breakvenstopnum<=costprice then
stopline:=costprice;
if stopline<costprice and low+trailingstopnum<=stopline then
stopline:=low+trailingstopnum;
end
老师,我这个策略信号乱了,我不知道是哪的原因,帮我看一下,谢谢
input:initialstop(20,10,60,10);
input:breakvenstop(20,10,60,10);
input:trailingstop(30,10,60,10);
input:money(2,1,10,1);
variable:stopline:=0;
begin
//predayhigh:=callstock(stklabel,vthigh,6,-1);//昨高
//predaylow:=callstock(stklabel,vtlow,6,-1);//昨低
//predayopen:=callstock(stklabel,vtopen,6,0);//昨收
//上轨:昨高;
//下轨:昨低;
//手数:=SS;
dist1:=barslast(day <> ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayopen:= ref(open,dist1-1);
entrytime:=time>=0916000 and time<=144500;
exittime:time>=150000;
initialstopnum:=mindiff*initialstop;
breakvenstopnum:=mindiff*breakvenstop;
trailingstopnum:=mindiff*trailingstop;
marginratio:=18/100;
end
if holding=0 then begin
if predayopen<predayhigh and entrytime and high>=predayhigh+mindiff then
myentryprice:=max(open,predayhigh+mindiff);
mycash:=cash(0);
lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
lots:=min(lots1,lots2);
buy(1,lots,limitr,myentryprice);
stopline:=0;
end
if holding=0 then begin
if predayopen>predaylow and entrytime and low<=predaylow - mindiff then
myentryprice:=max(open,predayhigh-mindiff);
mycash:=cash(0);
lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
lots:=min(lots1,lots2);
BUYSHORT(1,lots,limitr,myentryprice);
stopline:=0;
end
if holding>0 then begin
costprice:=enterprice+mindiff;
if exittime then
sell(1,holding,limitr,open);
end
if stopline>0 and low<=stopline then
sell(1,holding,limitr,min(open,stopline));
if stopline=0 then begin
stopline:=enterprice-initialstopnum;
if stopline<costprice and high- breakvenstopnum>=costprice then
stopline:=costprice;
if stopline>=costprice and high-trailingstopnum>=stopline then
stopline:=high-trailingstopnum;
end
if holding<0 then begin
costprice:=enterprice-mindiff;
if exittime then
sellshort(1,holding,limitr,open);
if stopline>0 and high>=stopline then
sellshort(1,holding,limitr,max(open,stopline));
if stopline=0 then
stopline:=enterprice+initialstopnum;
if stopline>costprice and low+breakvenstopnum<=costprice then
stopline:=costprice;
if stopline<costprice and low+trailingstopnum<=stopline then
stopline:=low+trailingstopnum;
end
老师,我加进去了,白色的箭头没有了,但没有任何信号。这个策略是根据视频教程讲的菲阿里四价策略记录的笔记,为什么不执行的,我弄不了。