以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请教关于hans123加入止损止盈的改写 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=59578) |
-- 作者:fshrshilei -- 发布时间:2013/12/5 16:00:39 -- 请教关于hans123加入止损止盈的改写 在开盘30分钟后准备入场; 上轨=开盘后30分钟高点; 下轨=开盘后30分钟低点; 用法: 当价格突破上轨,买入开仓; 当价格跌穿下轨,卖出开仓。 止损: 当买入开仓后;最小价格变动N1个单位 止损。 当卖出开仓后;最小价格变动N2个单位止损。 止盈: 当买入开仓后:最小价格变动N3个单位止盈。 当卖出开仓后:最小价格变动N4个单位止盈。
如果止盈止损都不触及,收盘平仓。 请各位老师能帮忙写下代码。感谢!
|
-- 作者:jinzhe -- 发布时间:2013/12/5 16:03:08 -- 处理中,请稍等 |
-- 作者:fshrshilei -- 发布时间:2013/12/5 16:03:53 -- 谢谢老师。 |
-- 作者:jinzhe -- 发布时间:2013/12/5 16:33:20 --
//N1,N2,N3,N4可以自行定义 //适用周期一分钟 t1:=time>090000 and time<145500; if h>shanggui and t1 then buy(holding=0,1,market); if l<xiagui and t1 then buyshort(holding=0,1,market); if c-enterprice>n1*mindiff and holding<0 then sellshort(1,0,market);//止损空头 if enterprice-c>n2*mindiff and holding>0 then sell(1,0,market);//止损多头 if c-enterprice>n3*mindiff and holding>0 then sell(1,0,market);//多头止盈 if enterprice-c>n4*mindiff and holding<0 then sellshort(1,0,market);//空头止盈 if t2 then BEGIN sellshort(1,0,market); |
-- 作者:fshrshilei -- 发布时间:2013/12/5 17:56:01 -- 谢谢老师,能否稍微改动下 换成适用于5分钟的K线呢,因为我正常都是按5分钟操作的。 |
-- 作者:fshrshilei -- 发布时间:2013/12/5 18:02:33 -- //N1,N2,N3,N4可以自行定义 //适用周期一分钟 t1:=time>090000 and time<145500; if h>shanggui and t1 then buy(holding=0,1,market); if l<xiagui and t1 then buyshort(holding=0,1,market); if c-enterprice>n1*mindiff and holding<0 then sellshort(1,0,market);//止损空头 if enterprice-c>n2*mindiff and holding>0 then sell(1,0,market);//止损多头 if c-enterprice>n3*mindiff and holding>0 then sell(1,0,market);//多头止盈 if enterprice-c>n4*mindiff and holding<0 then sellshort(1,0,market);//空头止盈 if t2 then BEGIN sellshort(1,0,market); --------------------------------------------------------------------------------------- 在编译的时候还提示未定义T1,但是这句t1:=time>090000 and time<145500; 菜鸟问题较多,还请老师多多包涵。 |
-- 作者:fshrshilei -- 发布时间:2013/12/5 21:06:59 -- INPUT:N1(10,1,100,10),N2(10,1,100,10),N3(50,1,100,20),N4(50,1,200,20)
老师,在这句话后加个分号以后测试成功了。
经过测试以后,我发现设置的止损系数是10个点,但止损后发现会有大于10个点的情形出现。我对照图找了以后发现,应该是止损的时候按照当根止损K线的收盘时的价格计算的。 希望老师能帮我改成到10个点止损系数后,就按当时的价格立刻止损掉,等于是固定点数的止损。(止盈也是如此) 还有就是如果有止盈止损情况出现后,当日不在开仓。还有就是老师写的代码为什么注释是 适合一分钟的,希望能写成适合5分钟的。 感谢jinzhe老师百忙抽空解答菜鸟的问题。
|
-- 作者:jinzhe -- 发布时间:2013/12/6 9:10:46 -- 第一句,也就是input那句,最后少了一个分号 [此贴子已经被作者于2013/12/6 9:10:56编辑过]
|
-- 作者:jinzhe -- 发布时间:2013/12/6 9:14:48 -- 测评是做不到触发价的,只能是开高低收4个中的一个来编写,如果觉得收盘价不行,那么你改这个自己认为正确的价格
使用5分钟,把上面的
shanggui:=valuewhen(todaybar<=30,hhv(h,todaybar));
改成
shanggui:=valuewhen(todaybar<=6,hhv(h,todaybar)); |
-- 作者:fshrshilei -- 发布时间:2013/12/6 13:26:04 -- 加个50个点的止损!! 再次感谢jinzhe老师的耐心解答。
那样的话 止损 止盈 是不是无法使用一个固定的限值来说明。
然后就是 能不能在止损止盈以后 不在开单呢,意思就是一天只开一单。我测试了下后,止损过以后 当天还是会开单的。
|