Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共8 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:加入止损公式一直未能成功,郁闷

1楼
lty9055 发表于:2015/1/14 12:59:05

buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and buycond then buy(1,1,thisclose);
if holding=0 and sellcond then buyshort(1,1,thisclose);

 

老师,想在该策略上加入止损,一直弄不成,非常郁闷!

我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。

2楼
pyd 发表于:2015/1/14 13:09:15


if enterbars=1 and enterprice-l>=5 then sell(holding>0,holding,market);
if enterbars=1 and h-enterprice>=5 then sellshort(holding<0,holding,market);
if enterbars=2 and enterprice-l>=2 then sell(holding>0,holding,market);
if enterbars=2 and h-enterprice>=2 then sellshort(holding<0,holding,market);
if enterbars=3 and enterprice-l>=0 then sell(holding>0,holding,market);
if enterbars=3 and h-enterprice>=0 then sellshort(holding<0,holding,market);

if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);

[此贴子已经被作者于2015/1/14 13:09:27编辑过]
3楼
lty9055 发表于:2015/1/14 15:12:09
if enterbars=1 and enterprice-l>=5 then sell(holding>0,holding,market);
if enterbars=1 and h-enterprice>=5 then sellshort(holding<0,holding,market);
if enterbars=2 and enterprice-l>=2 then sell(holding>0,holding,market);
if enterbars=2 and h-enterprice>=2 then sellshort(holding<0,holding,market);
if enterbars=3 and enterprice-l>=0 then sell(holding>0,holding,market);
if enterbars=3 and h-enterprice>=0 then sellshort(holding<0,holding,market);

if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);

感谢老师!

有个地方改动一下,我不想在次周期开盘价执行止损,我想一当碰到了马上发出指令执行止损。这应该改为哪个?谢谢

4楼
jinzhe 发表于:2015/1/14 15:18:16
在图表交易里面设置为 固定时间间隔模式
5楼
lty9055 发表于:2015/1/14 16:14:52

我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。

 

老师,可能我写的不够明白,应该是次周期内如亏损5个点即时止损;在第二个周期内如比较上周期收盘价低2个点即时止损;在第三个周期内如比较上周期收盘价平本即时止损;在第四个周期内如盈利返回10%即时止盈。

 

已经止损了,就不能再开仓,这个公式放在系统内,经常出现平仓后又马上开仓的情况。

能不能用“止损”“止盈”符号在k线图中标识,如果是平空平多,很混乱。感谢老师!

6楼
pyd 发表于:2015/1/14 16:29:13

意思和上周期收盘价先比而不是和开仓价相比止损?

盈利返回10%是指盈利开仓价的10%?

7楼
lty9055 发表于:2015/1/14 17:31:26
是的,感谢老师
8楼
pyd 发表于:2015/1/15 9:29:55

VARIABLE:n=0,m=0;
buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
c1:VALUEWHEN(enterbars=1,c);//开仓后下根k的收盘价
c2:VALUEWHEN(enterbars=2,c);//开仓后第二根k的收盘价

if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and n=0 and buycond then  buy(1,1,thisclose);
if holding=0 and m=0 and sellcond then  buyshort(1,1,thisclose);

 

if enterbars=1 and enterprice-l>=5 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=1 and h-enterprice>=5 then begin
sellshort(holding<0,holding,market);
m:=1;
end

if enterbars=2 and c1-l>=2 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=2 and h-c1>=2 then begin
 sellshort(holding<0,holding,market);
 m:=1;
 end
if enterbars=3 and c2-l>=0 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=3 and h-c2>=0 then begin
sellshort(holding<0,holding,market);
m:=1;
end

if enterbars=4 and h-enterprice>=0.1*enterprice then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=4 and enterprice-l>=0.1*enterprice then begin
 sellshort(holding<0,holding,market);
m:=1;
end
if time=CLOSETIME(0) then begin//止损后不开仓第二天再开仓
 n:=0;
 m:=0;
end

[此贴子已经被作者于2015/1/15 9:45:01编辑过]
共8 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.04395 s, 3 queries.