if barstatus=1 then begin
highprice := high;
lowprice := low;
position := 0;
end
highprice:=max(h,ref(highprice,1));
lowprice:=min(l,ref(lowprice,1));
最高:highprice;
最低:lowprice;
上面是代码,我想记录从图标上第一根到当前bar的最高最低价,上面这段代码问题出在哪?
加载到图里,最高价输出不完全对,最低价没法输出,没见查到问题出在哪里,求助
INPUT:N(3),MAXHOLD(1)
if barstatus=1 then begin
highprice := high;
lowprice := low;
position := 0;
end
//refhigh:= ref(close,1),linethick0;
//refhigh: ref(highprice,1);
highprice:=max(h,ref(highprice,1));
lowprice:=min(l,ref(lowprice,1));
aaaa:barstatus,linethick0;
最高:highprice;
最低:lowprice;
//开多开空
if holding<=0 and h>=lowprice*(1+n/100) then begin
buy(holding<=0,1,LIMITR,lowprice*(1+n/100));
highprice:=h;
end
if holding>=0 and l<=highprice*(1-(n+0.1)/100) then begin
BUYSHORT(holding>=0,1,LIMITR,highprice*(1-(n+0.1)/100));
lowprice:=low;
end
//加多加空
buy(holding>0 and holding<maxhold and high>=ENTERPRICE*(1+n/100),1,LIMITR,ENTERPRICE*(1+n/100));
BUYSHORT(holding<0 and holding>0-maxhold and l<ENTERPRICE*(1-(n+0.1)/100),1,LIMITR,ENTERPRICE*(1-(n+0.1)/100));
持仓:HOLDING,linethick0;
我是想从高点向下转折百分之n就做空,从低点向上转折百分之n就做多
但是高低点一直取不对,检查了好久这个怎么改呢
1、参考2楼,可以直接用hhv和llv来获取当前的最高价和最低价的,没必要你的那种方式来一个个进行比较。
2、另外如果用你的那种方式来记录最高价和最低价,需要把highprice和lowprice定义为全局变量的,这来才行。