以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请问 固定止损 和 止盈语句怎么写?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=82630)

--  作者:y
--  发布时间:2015/8/11 12:47:53
--  请问 固定止损 和 止盈语句怎么写?
1,出现开仓后,与开仓价格相比,最大损失超过1.5%止损

2,当出现最大盈利后,与最大盈利价格相比,回落40%幅度后止盈


谢金老师!

--  作者:jinzhe
--  发布时间:2015/8/11 13:18:43
--  

以多头为例,空头请根据多头的写法自行编写

1.

holding>0 and (enterprice-close)/enterprice>0.015

2.

holding>0 and hhv(h,entebars+1)-close/hhv(h,enterbars+1)>0.4


--  作者:y
--  发布时间:2015/8/12 2:05:01
--  
以下是引用jinzhe在2015/8/11 13:18:43的发言:

以多头为例,空头请根据多头的写法自行编写

1.

holding>0 and (enterprice-close)/enterprice>0.015

2.

holding>0 and hhv(h,entebars+1)-close/hhv(h,enterbars+1)>0.4


金老师早上好!


第二句好象不行啊,我用笨办法算过了,是个很大的数值,任何情况下都大于0.4


图表上几乎都是当天开平仓


--  作者:y
--  发布时间:2015/8/12 2:22:31
--  
多头止损:=(enterprice-close)/enterprice>止损幅度;   

多头止盈:=hhv(h,enterbars+1)-close/hhv(h,enterbars+1)>止盈幅度;

空头止损:=(close-enterprice)/close>止损幅度;

空头止盈:=close/llv(l,enterbars+1)-llv(l,enterbars+1)>止盈幅度;

请问这样写行吗?

--  作者:jinzhe
--  发布时间:2015/8/12 9:13:36
--  

抱歉,逻辑不对了,第二个改成这样holding>0 and ((hhv(h,entebars+1)-enterprice)-(close-enterprice))/(hhv(h,enterbars+1)-enterprice)>0.4

[此贴子已经被作者于2015/8/12 9:13:51编辑过]

--  作者:y
--  发布时间:2015/8/12 13:05:04
--  
金老师,没关系的,谁又能没有失误呢。
请问:注释掉止损止盈的时候,开平仓的信号是"极准确"的,一旦加进止损止盈,信号就乱套了,当天开平仓反复无常,请老师帮忙检查下面这样写对吗?

INPUT:n(20,1,300),ss(1,1,100),zs(0.02,0.01,0.035),zy(0.5,0.1,0.9);

多头止损:=(enterprice-close)/enterprice>zs;   
多头止盈:=((hhv(h,enterbars+1)-enterprice)-(close-enterprice))/(hhv(h,enterbars+1)-enterprice)>zy;

空头止损:=(close-enterprice)/close>zs;
空头止盈:=(enterprice-(llv(l,enterbars+1))-(enterprice-close))/enterprice-(llv(l,enterbars+1))>zy;

//开仓规则控制=======================================
if  holding=0  and  开多条件  THEN  BEGIN
开多:BUY(1,ss,MARKET)COLORRED;
end
if  holding=0  and  开空条件  THEN  BEGIN
开空:BUYSHORT(1,ss,MARKET)COLORGREEN;
end
//止损止盈控制=======================================
if  holding>0  and  多头止损  THEN  BEGIN
多止:SELL(1,ss,MARKET)COLORYELLOW;
end
if  holding>0  and  多头止盈  THEN  BEGIN
多盈:SELL(1,ss,MARKET)COLORYELLOW;
end
//===================================================
if  holding<0  and  空头止损  THEN  BEGIN 
空止:SELLSHORT(1,ss,MARKET)COLORYELLOW;
end
if  holding<0  and  空头止盈  THEN  BEGIN  
空盈:SELLSHORT(1,ss,MARKET)COLORYELLOW;
end

--  作者:jinzhe
--  发布时间:2015/8/12 13:23:00
--  

用固定轮询的吗?要用走完k线模式

 

或者在固定轮询模式下,把多仓的close 改成low,把空仓的close改成high


--  作者:y
--  发布时间:2015/8/12 13:40:35
--  
以下是引用jinzhe在2015/8/12 13:23:00的发言:

用固定轮询的吗?要用走完k线模式

 

或者在固定轮询模式下,把多仓的close 改成low,把空仓的close改成high




是逐K模式,没有用序列


--  作者:jinzhe
--  发布时间:2015/8/12 13:46:37
--  
不是,我说的固定时间间隔和走完k线指的是这个,不是序列计算和逐k计算
图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

--  作者:y
--  发布时间:2015/8/12 13:52:22
--  
打开图表程式化窗口检查了,默认的就是“走完一根K线后”