以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4) ---- 请教一句代码的意思 (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=167501) |
-- 作者:m1978xz -- 发布时间:2019/1/3 19:34:24 -- 请教一句代码的意思 下边这个策略是之前阿火版主在论坛发的,其中紫色这一行的我看不懂。这个date我在系统函数中查到是年月日的意思。但我取消这个变量后边的=号之后,在主图左上角显示的NN数值总是介于1到100之间,请问这是怎么计算出来的? INPUT:m(2,2,100,1);//设定参数M的默认值为2,最小值为2,最大值为100,步长为1 variable:zs=c,maxhl=c;//设定全局变量:zs=收盘价 maxhl=收盘价
DISTL:=NEWLBARS(L,1);//给DISTL赋值:今天的最低价,创了最近多少天的新低 DISTH:=NEWHBARS(H,1);//给disth赋值,今天的最高价,创了最近多少天的新高 HI20:=REF(HHV(H,20),1);//给hi20赋值:从一天 前开始算的20天中最高价的最高值。 LO20:=REF(LLV(L,20),1);//给Lo20赋值:从一天前开始算的20天内最低价的最低值。 GBD1:=REF(L,DISTL);//给GBD1赋值:前低的值 GBD2:=REF(GBD1,DISTL);//前前低值 GBD:=IF(GBD2>0,MAX(LLV(L,20),GBD2),LLV(L,20));//如果前前低的值大于零,返回20天内最低值或者前前低的值,选其中最大的那个。否则返回20天内的最低值。
GBG1:=REF(H,DISTH);//给GBG1赋值:前高的值 GBG2:=REF(GBG1,DISTH);//给GBG2赋值:前前高的值 GBG:=IF(GBG2>0,MIN(HHV(H,20),GBG2),HHV(H,20));//如果前前高的值大于零,返回20天内最高值或者前前高的值,选其中最小的那个。否则返回20天内的最高值。
nn:=barslast(date<>ref(date,1))+1; entertime:=nn>=m and time<=144500; exittime:=time>=150900; if holding>0 then 止损1:zs; if holding<0 then 止损2:zs; ma5:=ma(c,5); ma30:=ma(c,30); long:=cross(ma5,ma30);//多单进场条件 short:=cross(ma30,ma5);//空单进场条件
//下破移动止损线后离场 if holding>0 and (c<zs or exittime) then sell(1,1,limitr,c); if holding<0 and (c>zs or exittime) then sellshort(1,1,limitr,c);
//开仓语句
if holding=0 and entertime and long then begin buy(1,1,limitr,c); zs:=gbd;//调用顾比倒数线做为止损 maxhl:=h;//记录当时的高点 end
if holding=0 and entertime and short then begin buyshort(1,1,limitr,c); zs:=gbg;//调用顾比倒数线做为止损 maxhl:=L; end
if holding<0 and l<maxhl then begin //创新低后,重新定位离场位,以实现浮动止损 maxhl:=l; zs:=gbg; end
if holding>0 and h>maxhl then begin //创新高后,重新定位离场位,以实现浮动止损 zs:=gbd; maxhl:=h; end |
-- 作者:FireScript -- 发布时间:2019/1/4 8:48:57 -- 当前K的位置是当日第多少个K。 |