以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 怎样向前赋值 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=74247) |
-- 作者:yin8jun -- 发布时间:2015/1/9 16:20:47 -- 怎样向前赋值 我的系统是一手一手开,一手一手平的。现在持多单,手数为a:holding,我需要引用开第a-1手时的价格。我该怎么办? 这个问题的难点是把现在的holding定义成一个固定常数往回赋值。
|
-- 作者:jinzhe -- 发布时间:2015/1/9 16:34:30 -- 把你的代码都贴一下,你这样的描述我们不好理解 |
-- 作者:yin8jun -- 发布时间:2015/1/9 17:15:44 -- 请看如下,假如我开了6手多单,然后平了3手,手上还有3手,我要引用当初开第3手的价格。 variable:izhisun=0; variable:kdcs=0;//kd次数 variable:kkcs=0;//kk次数 variable:dfjb=0; starttime:=093500; endtime:=143000; ss:=1; zs:=6; 资产:asset-1000000,noaxis,colorred,linethick2; 胜率:percentwin,linethick0; 交易次数:totaltrade,linethick0; 持仓:holding,linethick0; dfj:=date>ref(date,1); dfjb:=barslast(dfj)+1; if dfj {or time>151000} then begin izhisun:=0.001*o*zs; kdcs:=0; kkcs:=0; end refc:=ref(c,1); refo:=ref(o,1); if time>=starttime and time<=143000 then begin if mod(minute,5)=0 and refc>refo then begin if holding>=0 and kdcs<15 and totaldaytrade<10 then begin buy(1,ss,limitr,c); kdcs:=kdcs+1; holdh:=h; end end end //时间平仓 if time>=150800 then begin if holding>0 then sell(1,holding,limitr,o); if holding<0 then sellshort(1,holding,limitr,o); end if holding>0 and enterprice-l>=izhisun then begin sell(1,1,limitr,enterprice-izhisun);//止损 end |
-- 作者:jinzhe -- 发布时间:2015/1/9 17:19:31 -- valuewhen(holding=3 and ref(holding=2,1),enterprice); 这个写在开仓语句后面 |
-- 作者:yin8jun -- 发布时间:2015/1/14 15:48:12 -- 手上有三手是打个比方。比如手上有i手时呢,怎么办?i取值holding后再往回赋值? |
-- 作者:jinzhe -- 发布时间:2015/1/14 15:55:16 -- 一样,获取第I手的下单价格就是valuewhen(holding=i and ref(holding=i-1,1),enterprice) |
-- 作者:yin8jun -- 发布时间:2015/1/14 16:33:54 -- 你试过没?加入 i:=holding; aa:valuewhen(holding=i and ref(holding=i-1,1),enterprice),noaxis; aa永远都是0.
|
-- 作者:jinzhe -- 发布时间:2015/1/14 16:45:27 -- i怎么会是等于holding? 你前面说是要6手中的第三手 所以I就是3 怎么到了你那里就变成6了? |
-- 作者:yin8jun -- 发布时间:2015/1/14 17:08:38 -- 我说的假如目前是3手。i:=目前的手数.请看标题,如果是固定手数,那就简单了,不是难题了啊 |
-- 作者:yin8jun -- 发布时间:2015/1/14 17:09:38 -- 问题的关键是怎么把现在的手数赋值成一个向回赋值的常数吧。 |