以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (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=159517) |
-- 作者:158021589560 -- 发布时间:2017/11/14 13:16:19 -- 如何实现这种平仓方式 请问老师,如何实现当盈利大于50点时候,收盘价格低于(boll1)平仓,当盈利大于80点时候,收盘价格低于(boll2)平仓,然后下面的平仓方式也保持不变,请问如何写代码?万分感谢!!! LastBollTime:ref(time,BARSLAST(BOLL<REF(BOLL,1)));//表示上次BOLL<REF(BOLL,1)的时候的time LastBollTime1:ref(time,BARSLAST(BOLL>REF(BOLL,1)));//表示上次BOLL<REF(BOLL,1)的时候的time PD:time-LastBollTime1>60*5 AND C<下; PK:time-LastBollTime>60*5 AND C>上; PD3:=BOLL_60<BOLL_昨天60; PK3:=BOLL_60>BOLL_昨天60; //交易系统 平空:SELLSHORT((PK OR PK3) and enterbars>0,8,MARKET); //平空信号 开多:BUY(KD AND HOLDING=0,8,MARKET); //开多信号 平多:SELL((PD OR PD3) AND enterbars>0,8,MARKET); //平多信号 开空:BUYSHORT(KK AND HOLDING=0,8,MARKET);//开空信号 |
-- 作者:158021589560 -- 发布时间:2017/11/14 13:18:49 -- 还有一个是,当盈利超过200点,立马平仓(不是收盘价也不是次周期价格) |
-- 作者:FireScript -- 发布时间:2017/11/14 13:58:49 -- 确认下需求情况: 你是要在原先代码基础上增加平仓条件对吧。 1.盈利大于50点小于80点的时候:收盘价<boll1 则平仓 2. 盈利大于80点的时候 :收盘价<boll2 则平仓 3. 盈利200点的时候 :市价平仓
你这个盈利是什么盈利,最近一次交易的盈利吗?此外你的boll1和boll2的定义在什么地方?是你自己输入的值? |
-- 作者:158021589560 -- 发布时间:2017/11/14 21:02:47 -- 老师,1,2,3需求都对的,盈利是指最近一次交易的盈利。 boll是我自己输入的值,这个boll我可以自己调试 |
-- 作者:yukizzc -- 发布时间:2017/11/15 9:03:20 -- if OPENPROFIT>50 and OPENPROFIT<80 and close<boll1 then sell(1,holding,marketr);
if OPENPROFIT>80 and close<boll2 then sell(1,holding,marketr); |
-- 作者:FireScript -- 发布时间:2017/11/15 9:28:24 -- 代码样例如下:你整合到你自己原先代码里面去吧。 input:boll1(5,1,100,1),boll2(5,1,100,1);//参数输入 if Profit>=50*MINDIFF and Profit<80*MINDIFF and c<boll1 then if Profit>=80*MINDIFF and c<boll2 then if Profit>200*MINDIFF then |
-- 作者:158021589560 -- 发布时间:2017/11/15 10:49:01 -- 这串代码放在什么位置,是交易条件里面吗 |
-- 作者:FireScript -- 发布时间:2017/11/15 11:16:56 -- 参数输入的那个放代码第一行去,其他的放到你原先代码后面去。 |
-- 作者:158021589560 -- 发布时间:2017/11/24 16:38:25 -- 代码样例如下:你整合到你自己原先代码里面去吧。 input:boll1(5,1,100,1),boll2(5,1,100,1);//参数输入 if Profit>=50*MINDIFF and Profit<80*MINDIFF and c<boll1 then if Profit>=80*MINDIFF and c<boll2 then if Profit>200*MINDIFF then 这串代码里面当盈利超过50小于80时候,收盘价小于boll1平多或平空、 我想把这段分开写,平多是收盘价小于boll,平空是收盘价大于boll3,超过80和200 的也需要分开写。 [此贴子已经被作者于2017/11/24 16:39:40编辑过]
|
-- 作者:158021589560 -- 发布时间:2017/11/24 18:56:38 -- temp:=c-ENTERPRICE; if holding>0 then Profit:=temp;else if holding<0 then Profit:=(-temp); if holding=0 then Profit:=0; if Profit>40*MINDIFF and Profit<80*MINDIFF and C<WU then sell(holding>0,1,MARKET); if Profit>40*MINDIFF and Profit<80*MINDIFF and C>WB then sellshort(holding<0,1,MARKET); if Profit>80*MINDIFF and c<上 then sell(holding>0,1,MARKET); if Profit>80*MINDIFF and c>下 then sellshort(holding<0,1,MARKET); if Profit>150*MINDIFF then begin sell(holding>0,1,MARKET); sellshort(holding<0,1,MARKET); end VARIABLE:isProfit=0; if Profit>10*MINDIFF and isProfit=0 then isProfit:=1; if ISProfit and Profit<=2*MINDIFF then begin sell(holding>0,1,MARKET); sellshort(holding<0,1,MARKET); isProfit:=0;//平仓后全局变量重置为0 end 这样写可以吗?
|