以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请教问题 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=61053) |
-- 作者:punkcat401 -- 发布时间:2014/1/17 12:04:28 -- 请教问题 请问以下思路应该怎么写: 多空双向开仓时,做多后,有A B C三种平多仓的方式。 连续三次多头平仓后是盈利的(包括隔夜,今日之前的都算),则全局变量N:=1。 |
-- 作者:jinzhe -- 发布时间:2014/1/17 13:50:54 -- aa:=asset; a1:=ref(asset,todaybar); variable:k=0; if 平仓条件a and 持仓判断 then begin 平仓语句; k:=k+1; end if 平仓条件b and 持仓判断 then begin 平仓语句; k:=k+1; end if 平仓条件c and 持仓判断 then begin 平仓语句; k:=k+1; end
if k=3 and aa-a1>0 then n:=1;
if date<>ref(date,1) then k:=0; |
-- 作者:punkcat401 -- 发布时间:2014/1/17 14:02:54 -- 我描述的不准确,应该是每次多头平仓后都是盈利的,这样连续三次
而不是平仓三次后,总和是盈利的,所以没法用ref(asset,todaybar)来比较
连续三次盈利,是包括隔夜的,不要求都在日内,不用初始化为0吧,if date<>ref(date,1) then k:=0;
|
-- 作者:jinzhe -- 发布时间:2014/1/17 14:27:22 -- variable:k=0; if 平仓条件a and 持仓判断 then begin 平仓语句; if numprofit(1)>0 then k:=k+1; if numprofit(1)<=0 then k:=0; end if 平仓条件b and 持仓判断 then begin 平仓语句; if numprofit(1)>0 then k:=k+1; if numprofit(1)<=0 then k:=0; end if 平仓条件c and 持仓判断 then begin 平仓语句; if numprofit(1)>0 then k:=k+1; if numprofit(1)<=0 then k:=0; end
if k=3 then n:=1;
|