以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  老师你好  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=163208)

--  作者:金之塔
--  发布时间:2018/5/4 13:37:11
--  老师你好
请老师帮忙写一个,在1分钟周期或者5分钟周期 1:取得今天的开盘价 2如果现在价格大于开盘价那么开多,如果小于开空。2如果亏损p*mindiff多单空单都平仓。3如果赢了2P*mindiff多单空单都止盈。谢谢老师
--  作者:金之塔
--  发布时间:2018/5/4 13:38:32
--  
用固定轮训的模式,不会闪烁。谢谢老师了
--  作者:金之塔
--  发布时间:2018/5/4 14:12:31
--  
没有人回答吗
--  作者:FireScript
--  发布时间:2018/5/4 14:25:25
--  
 top:ref(o,TODAYBAR);

if c>top and holding=0 then buy(1,1,MARKET);
if c<top and holding=0 then buyshort(1,1,MARKET);

if holding>0 and ENTERPRICE-c>P*MINDIFF then sell(1,holding,market);
if holding<0 and c-ENTERPRICE>P*MINDIFF then sellshort(1,holding,market);

if holding>0 and c-ENTERPRICE>2*P*MINDIFF then sell(1,holding,market);
if holding<0 and ENTERPRICE-c>2*P*MINDIFF then sellshort(1,holding,market);
--  作者:金之塔
--  发布时间:2018/5/4 14:29:07
--  
不能用现价交易:limitr?
--  作者:金之塔
--  发布时间:2018/5/4 14:31:28
--  
不要用下根K线的开盘价或者这根K线的收盘,就是到了条件就执行。你这样写固定轮训会出现闪烁啊。忘开始改一下
--  作者:FireScript
--  发布时间:2018/5/4 14:37:59
--  
可以用限价的, 到了条件就执行这个是要选择固定轮询模式,并不是代码里面控制的。你这个也做不到不闪烁,因为你下单条件在行情上下变化的时候是很容易反复变化的。
“如果现在价格大于开盘价那么开多”这个条件没办法让它不闪烁的。

--  作者:金之塔
--  发布时间:2018/5/4 14:40:22
--  
用最高价,或者最低价来写,不是可以吗
--  作者:FireScript
--  发布时间:2018/5/4 14:44:58
--  
  top:ref(o,TODAYBAR);

if h>top and holding=0 then buy(1,1,MARKET);
if l<top and holding=0 then buyshort(1,1,MARKET);

if holding>0 and ENTERPRICE-c>P*MINDIFF then sell(1,holding,market);
if holding<0 and c-ENTERPRICE>P*MINDIFF then sellshort(1,holding,market);

if holding>0 and c-ENTERPRICE>2*P*MINDIFF then sell(1,holding,market);
if holding<0 and ENTERPRICE-c>2*P*MINDIFF then sellshort(1,holding,market);

那可以稍微改下,开仓条件。 限价指令那个你可以参考下单函数的说明自行修改下就行了。

--  作者:金之塔
--  发布时间:2018/5/4 14:52:44
--  
 top:ref(o,TODAYBAR);

if h>top and holding=0 then buy(1,1,LIMITR,top);
if l<top and holding=0 then buyshort(1,1,LIMITR,top);

if holding>0 and ENTERPRICE-l>P*MINDIFF then sell(1,holding,LIMITR,ENTERPRICE-p*mindiff);
if holding<0 and h-ENTERPRICE>P*MINDIFF then sellshort(1,holding,LIMITR,ENTERPRICE+p*MINDIFF);

if holding>0 and h-ENTERPRICE>2*P*MINDIFF then sell(1,holding,LIMITR,ENTERPRICE+2*p*MINDIFF);
if holding<0 and ENTERPRICE-l>2*P*MINDIFF then sellshort(1,holding,LIMITR,ENTERPRICE-2*p*MINDIFF);


我这样改就会出现问题,请老师指正