以文本方式查看主题

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

--  作者:sunjach
--  发布时间:2017/7/19 11:24:02
--  请老师编写个策略
当收盘价同时向上穿越10日和5日MA时,开多
当收盘价同时向下穿越10日和5日MA时,开空
附加条件: 穿越当根K线的最高至最低幅度在15跳范围内,才满足开仓条件
止盈条件:当开仓价格大于15个点时,才触发止损条件保本,启动移动止盈跟踪,即 例如,3500开多,现价超过3515时,开始启动保本跟踪止盈
止损条件:当现价亏损达到15个点时,直接止损。

--  作者:pyd
--  发布时间:2017/7/19 12:32:53
--  
编写中请稍等
--  作者:pyd
--  发布时间:2017/7/19 12:46:17
--  


多头为例,空头你参照着写

VARIABLE:n=0;
ma5:ma(c,5);
ma10:ma(c,10);
kd:=cross(c,ma5) and cross(c,ma10);
kk:=cross(ma5,c) and cross(ma10,c);
if kd and h-l<=15*mindiff and holding=0 then buy(1,1,marketr);
if kk and h-l<=15*mindiff and holding=0 then buyshort(1,1,marketr);
if hhv(h,enterbars+1)-enterprice>=15 then n:=1;
if n=1 and c-enterprice>=15 and holding>0 then begin
sell(1,1,marketr);
n:=0;
end

if enterprice-c>=15 and holding>0 then sell(1,1,marketr);


--  作者:sunjach
--  发布时间:2017/7/19 13:45:22
--  
不好意思 老师,自己还不会呢,才试着看,您帮我先写下了,谢谢!
--  作者:pyd
--  发布时间:2017/7/19 14:07:47
--  

学习资料http://www.weistock.com/bbs/dispbbs.asp?boardid=2&Id=55146

VARIABLE:n=0,m=0;
ma5:ma(c,5);
ma10:ma(c,10);
kd:=cross(c,ma5) and cross(c,ma10);
kk:=cross(ma5,c) and cross(ma10,c);

if kd and h-l<=15*mindiff and holding=0 then buy(1,1,marketr);//开多

if hhv(h,enterbars+1)-enterprice>=15 then n:=1;
if n=1 and c-enterprice<=15 and holding>0 then begin //多头移动止盈
sell(1,1,marketr);
n:=0;
end

if enterprice-c>=15 and holding>0 then sell(1,1,marketr); //多头止损
 

if kk and h-l<=15*mindiff and holding=0 then buyshort(1,1,marketr);//开空

if enterprice-llv(l,enterbars+1)>=15 then m:=1;
if m=1 and enterprice-c<=15 and holding<0 then begin  //空头移动止盈
sellshort(1,1,marketr);
m:=1;
end

if c-enterprice>=15 and holding<0 then sell(1,1,marketr);//空头止损


--  作者:sunjach
--  发布时间:2017/7/19 14:16:12
--  
老师,还有个条件忘记了,就是开仓条件的反向条件出现时,也是平掉原有的仓。例如,阳K线穿双线开了多单,反过来阴线反穿双均线时,也要平仓,如果满足开空条件时,直接反手。
--  作者:wenarm
--  发布时间:2017/7/19 14:50:11
--  

你这非条件不是已经被你上面的条件包含了吗?

上穿两个均线的k,不管是红还都会开仓的,平仓条件也是一样的

[此贴子已经被作者于2017/7/19 15:01:52编辑过]

--  作者:sunjach
--  发布时间:2017/7/19 15:54:38
--  
开仓条件有一个点数限制,平仓要反向条件出现,先平仓再判断是否符合开仓
--  作者:wenarm
--  发布时间:2017/7/19 16:23:31
--  

不明白你说的,。你一把条件从新整理说明,并详细表达每个条件之间的关系