Rss & SiteMap

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

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

标题:[原创]

1楼
苦麻菜真好吃 发表于:2016/4/27 14:26:30
以均线ma1、ma2的金死叉为开仓条件:
请老师帮我编写止损部分:1、开仓后以下面的QD、QG为初始止损
                                2、当开仓后盈利20*MINDIFF后、将止损位移到保本止损(开仓价位)
                                3、加仓条件:当止损位移至保本价位后,若价格在均线ma2上(下)并且满足条件1时,加仓一手,
                                     
                                       当止损移至保本价位后,则当ma1、ma2、金死叉时平仓出场。



                              (麻烦老师把多空的出场都写出来,谢谢)
                      



条件1:

if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
   sellshort(1,0,marketr);
   buy(holding=0,1,marketr);
end
 
if all(macd<0,4) and all(macd<ref(macd,1),4) then begin
   sell(1,0,marketr);
   buyshort(holding=0,1,marketr);
end





nn1:=sumbars(cross(macd,0),1);
nn2:=sumbars(cross(0,macd),1);
QD:valuewhen(holding>0,ref(ref(llv(l,nn2),nn1),enterbars));//初始止损位
QG:valuewhen(holding<0,ref(ref(hhv(h,nn1),nn2),enterbars));//初始止损位





2楼
jinzhe 发表于:2016/4/27 14:37:58

3、加仓条件:当止损位移至保本价位后,若价格在均线ma2上(下)并且满足条件1时,加仓一手,

 

 

这里的条件1指的是什么?

3楼
苦麻菜真好吃 发表于:2016/4/27 14:53:35
条件1是下面这两句:

多头加仓:if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
   

 
空头加仓:if all(macd<0,4) and all(macd<ref(macd,1),4) then begin




   

4楼
jinzhe 发表于:2016/4/27 15:13:39

variable:bj=0;
if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
   sellshort(1,0,marketr);
   buy(holding=0,1,marketr);
   bj:=0
end
 
if all(macd<0,4) and all(macd<ref(macd,1),4) then begin
   sell(1,0,marketr);
   buyshort(holding=0,1,marketr);
   bj:=0;
end

 

nn1:=sumbars(cross(macd,0),1);
nn2:=sumbars(cross(0,macd),1);
QD:valuewhen(holding>0,ref(ref(llv(l,nn2),nn1),enterbars));//初始止损位
QG:valuewhen(holding<0,ref(ref(hhv(h,nn1),nn2),enterbars));//初始止损位

if c<qd and holding>0 then sell(1,0,marketr);
if c>qg and holding<0 then sellshort(1,0,marketr);

if holding>0 and hhv(h,enterbars+1)>enterprice+20*mindiff and c<enterprice then begin
 sell(1,0,marketr);
 bj:=1;
end
if holding<0 and llv(l,enterbars+1)<enterprice-20*mindiff and c>enterprice then begin
 sellshort(1,0,marketr);
 bj:=-1;
end

if bj=1 and c>ma2 and all(macd>0,4) and all(macd>ref(macd,1),4) then buy(1,1,marketr);
if bj=-1 and c<ma2 and  all(macd<0,4) and all(macd<ref(macd,1),4) then buyshort(1,1,marketr);

if bj=1 and cross(ma1,ma2) then sell(1,0,marketr);
if bj=-1 and cross(ma2,ma1) then sellshort(1,0,marketr);

5楼
苦麻菜真好吃 发表于:2016/4/28 9:21:46
这样写不对,我另外换个说法吧、没有加仓这动作。

以均线ma1、ma2的金死叉为开仓条件:
请老师帮我编写止损部分:1、开仓后以下面的QD、QG为初始止损
                                2、当开仓后盈利20*MINDIFF后、将止损位移到保本止损(开仓价位)
                                3、  当止损移至保本价位后,把平仓条件改为ma1,ma2金死叉出场、而不是依然是等到回落到保本才平仓。




if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
   

 if all(macd<0,4) and all(macd<ref(macd,1),4) then begin   这两句不做为开仓条件



6楼
jinzhe 发表于:2016/4/28 9:27:46
那么满足条件2之后是直接执行条件3了?条件2就算是回落到开仓价了也不平?
7楼
苦麻菜真好吃 发表于:2016/4/28 9:34:48
满足条件2之后是直接执行条件3,条件2就算是回落到开仓价了也平,优先执行条件3的平仓方式
8楼
jinzhe 发表于:2016/4/28 9:45:14


if all(macd>0,4) and all(macd>ref(macd,1),4) then begin
   sellshort(1,0,marketr);
   buy(holding=0,1,marketr);
   bj:=0
end
 
if all(macd<0,4) and all(macd<ref(macd,1),4) then begin
   sell(1,0,marketr);
   buyshort(holding=0,1,marketr);
   bj:=0;
end

 

nn1:=sumbars(cross(macd,0),1);
nn2:=sumbars(cross(0,macd),1);
QD:valuewhen(holding>0,ref(ref(llv(l,nn2),nn1),enterbars));//初始止损位
QG:valuewhen(holding<0,ref(ref(hhv(h,nn1),nn2),enterbars));//初始止损位

if c<qd and holding>0 and hhv(h,enterbars+1)<enterprice+20*mindiff then sell(1,0,marketr);
if c>qg and holding<0 and llv(l,enterbars+1)>enterprice-20*mindiff then sellshort(1,0,marketr);


if hhv(h,enterbars+1)>enterprice+20*mindiff and holding>0 and cross(ma1,ma2) then sell(1,0,marketr);
if llv(l,enterbars+1)<enterprice-20*mindiff and holding<0 and cross(ma2,ma1) then sellshort(1,0,marketr);

[此贴子已经被作者于2016/4/28 9:53:11编辑过]
9楼
苦麻菜真好吃 发表于:2016/4/28 11:17:45
还是没办法实现、我想是我表达不清楚、我再从新表达一遍吧。
多设置一根均线ma3

以均线金叉为入场条件:当ma1和ma2金叉时开仓做多:1、cross(ma1,ma2) 买入,入场后以QD(前低)做为初始止损
                                                                       2、当最高盈利20*mindiff后将止损位调整为保本止损
                                                                                         3、当盈利20*mindiff并且cross(ma1,ma3) ,则以cross(ma3,ma1) 做为出场方式
                                                                                 
                                                                                              谢谢!
10楼
jinzhe 发表于:2016/4/28 11:21:54
上面基本上就是了,你改改条件就成了,
共10 条记录, 每页显示 10 条, 页签: [1]


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