以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  老师请问当根K线收盘价大于开盘价就开多,如果开多后来不及平多价格已经跌破开盘价就反手开空,反之开空也是如此,请问如何编写模型,谢谢。  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=64731)

--  作者:sx
--  发布时间:2014/5/7 11:14:43
--  老师请问当根K线收盘价大于开盘价就开多,如果开多后来不及平多价格已经跌破开盘价就反手开空,反之开空也是如此,请问如何编写模型,谢谢。
 老师请问当根K线收盘价大于开盘价就开多,如果开多后来不及平多价格已经跌破开盘价就反手开空,反之开空也是如此,请问如何编写模型,谢谢。 
--  作者:jinzhe
--  发布时间:2014/5/7 11:26:12
--  

如果是走完k线下单模式那么就这样写

if c>o then  buy......;

if holding>0 and close<enterprice then begin

    sell........;

    buyshort......;

end

 

if c<o then buyshort.......;

if holding<0 and close>enterprice then begin

      sellshort.........;

     buy......;

end

 

如果是固定时间间隔模式那么就这样写

 

if h>o then  buy......;

if holding>0 and l<enterprice then begin

    sell........;

    buyshort......;

end

 

if l<o then buyshort.......;

if holding<0 and h>enterprice then begin

      sellshort.........;

     buy......;

end


--  作者:sx
--  发布时间:2014/5/7 11:39:10
--  
老师,buy......;如何定义,谢谢。
--  作者:qq代人发帖
--  发布时间:2014/5/7 12:46:38
--  

说明

交易系统之开多操作

语法

BUY(COND,V,Type,P);表示当COND条件成立时,

买入V股(手)当前品种,TYPE表示买入类型,

P表示买入价格,所有参数均可以省略。

V:买入股(手)数或买入资金百分比(N%),若为0或者省略表示100%;

TYPE:可以是本周期收盘(THISCLOSE),市价(MARKET),

限价单(LIMIT),停损单(STOP)等交易方式控制符;

P:对于限价单、停损单需要指定的买入价格

参数

备注

该函数仅在逐K线计算模式下有效

示例

BUY(C>O ,1000,THISCLOSE);表示收阳线则在本周期收盘价上买入1000股(手)。

BUY(C>0,50%,LIMIT,CLOSE-0.2);表示在指定限价CLOSE-0.2元位置下买入限价单,

若价格达到或低于该价格则用50%资金买入。

所属函数组

交易系统


--  作者:sx
--  发布时间:2014/5/7 14:15:16
--  
老师,模型不会反手,谢谢。
--  作者:jinzhe
--  发布时间:2014/5/7 14:20:01
--  
这个不会,贴上你的代码
--  作者:sx
--  发布时间:2014/5/7 14:27:48
--  

if h>o then  buy(C>O ,1000,THISCLOSE);

if holding>0 and l<enterprice then begin

 

    sell(C<O ,1000,THISCLOSE);

    buyshort(C<O ,1000,THISCLOSE);

 

end;

 

 

 

if l<o then buyshort(C<O ,1000,THISCLOSE);

if holding<0 and h>enterprice then begin

 

      sellshort(C>O ,1000,THISCLOSE);

     buy(C>O ,1000,THISCLOSE);

 

end;

<!--EndFragment-->
--  作者:qq代人发帖
--  发布时间:2014/5/7 14:44:40
--  

您这种是选用2楼固定轮询的写法,为什么又掺杂了走完K的(c>o,c<o),

我把它换成了holding=0,holding<0,holding>0的判断

平多后立马开空  或平空后立马开多就叫反手

if h>o then  buy(holding=0 ,1000,THISCLOSE);

if holding>0 and l<enterprice then begin

 
sell(holding>0 ,1000,THISCLOSE);//平多

buyshort(holding=0 ,1000,THISCLOSE);//反手开空

end;

 
if l<o then buyshort(holding=0 ,1000,THISCLOSE);

if holding<0 and h>enterprice then begin

sellshort(holding<0 ,1000,THISCLOSE);//平空

buy(holding=0 ,1000,THISCLOSE);//反手开多

end;

 


--  作者:sx
--  发布时间:2014/5/7 15:11:57
--  

老师我的意思是每一根k线都要有信号,谢谢。

比如当根K线开盘上涨做多,下一K线如果继续上涨还是做多直至有一K线下跌就反手做空。

<!--EndFragment-->
--  作者:qq代人发帖
--  发布时间:2014/5/7 15:58:10
--  

把holding持仓判断换成1,只有if 条件成立 就会开平仓,每根k都有信号

if h>o then buy(1,1000,THISCLOSE);

if holding>0 and l<enterprice then begin


sell(1 ,1000,THISCLOSE);//平多

buyshort(1 ,1000,THISCLOSE);//反手开空

end;


if l<o then buyshort(1 ,1000,THISCLOSE);

if holding<0 and h>enterprice then begin

sellshort(1 ,1000,THISCLOSE);//平空

buy(1,1000,THISCLOSE);//反手开多

end;