以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- [求助]单次连盈和连亏的函数编写 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=74157) |
-- 作者:modaihuoying -- 发布时间:2015/1/8 10:37:40 -- [求助]单次连盈和连亏的函数编写 我用图标程序化交易,需要获得连续2次盈利后记数为2,连续3次盈利记数为3,后面如果有亏损则清零,再遇到盈利重新记数,请问要怎么编写啊? |
-- 作者:jinzhe -- 发布时间:2015/1/8 10:55:55 -- variable:n=0,m=0; if 平多条件 and holding>0 then begin sell(1,0,market); if numprofit(1)>0 and numprofit(2)>0 then n:=n+1; if numprofit(1)<0 and numprofit(2)<0 then m:=m+1; if numprofit(1)>=0 and numprofit(2)<=0 then n:=1; if numprofit(1)<=0 and numprofit(2)>=0 then m:=1; end
if 平空条件 and holding>0 then begin sellshort(1,0,market); if numprofit(1)>0 and numprofit(2)>0 then n:=n+1; if numprofit(1)<0 and numprofit(2)<0 then m:=m+1; if numprofit(1)>=0 and numprofit(2)<=0 then n:=1; if numprofit(1)<=0 and numprofit(2)>=0 then m:=1; end
n是连赢次数,m是连亏次数 |