以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请问老师怎么编写这个 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=87390) |
-- 作者:qq代人发帖 -- 发布时间:2015/11/17 15:25:18 -- 请问老师怎么编写这个 请问,默认交易手数为2,如果上一笔交易亏损,则本次交易1手;如果上一笔交易盈利,则本次交易2手。这个交易思路应该怎么写?
|
-- 作者:jinzhe -- 发布时间:2015/11/17 15:32:48 -- ss:=2;//交易手数为2手
if 平多条件 and holding>0 then begin sell(1,0,market); if numprofit(1)>=0 then ss:=2; if numprofit(1)<0 then ss:=1; end
if 平空条件 and holding<0 then begin sellshort(1,0,market); if numprofit(1)>=0 then ss:=2; if numprofit(1)<0 then ss:=1; end
|
-- 作者:yiyihi -- 发布时间:2015/11/17 15:42:36 -- 抱歉,老师,可能我没说明白。 默认交易手数是2.策略为非多即空策略。 如果上一笔交易盈利,则本次交易开仓手数为2; 如果上一笔交易亏损,则本次交易开仓手数为1. 您写的好像只是平仓的部分。 |
-- 作者:jinzhe -- 发布时间:2015/11/17 15:47:12 -- variable:ss=2;//交易手数为2手
if 平多条件 and holding>0 then begin sell(1,0,market); if numprofit(1)>=0 then ss:=2; if numprofit(1)<0 then ss:=1; end
if 平空条件 and holding<0 then begin sellshort(1,0,market); if numprofit(1)>=0 then ss:=2; if numprofit(1)<0 then ss:=1; end
判断盈利之后,SS也跟着变了 SS要用全局变量,我前面重新定义了 [此贴子已经被作者于2015/11/17 15:47:53编辑过]
|
-- 作者:yiyihi -- 发布时间:2015/11/17 15:51:58 -- 需要把SS加入到SELL和SELLSHORT的语句里面去吗? |
-- 作者:jinzhe -- 发布时间:2015/11/17 15:58:40 -- 我已经加了,判断盈亏之后进行赋值 |