以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  AB条件同时成立只执行A  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=90816)

--  作者:fxrock4
--  发布时间:2016/1/29 14:04:14
--  AB条件同时成立只执行A
AB条件同时成立时只执行A交易。

开仓和加仓都是只执行A条件,这个要如何写,多谢。

--  作者:jinzhe
--  发布时间:2016/1/29 14:09:41
--  

意思是a是开多,b是开空,ab同时成立要开多?


--  作者:fxrock4
--  发布时间:2016/1/29 14:16:06
--  
A是一个限制性多的条件
B是一个限制性少的条件
A和B成立时都开多或开空
但当A成立时B不再执行开仓和加仓,而是只执行A。这样就不重复开仓和加仓了。

--  作者:jinzhe
--  发布时间:2016/1/29 14:21:44
--  

那么开仓语句这样写

if a or b then buy.....;


--  作者:fxrock4
--  发布时间:2016/1/29 14:49:28
--  
乱了。
当A条件成立时开仓20%,当B条件成立时开仓10%。二个条件同时成立时,只执行A条件开仓20%
当A条件下的C成立时加仓10%
当B条件下的C成立时加仓5%

--  作者:jinzhe
--  发布时间:2016/1/29 14:59:52
--  

variable:n=0;

variable:m=0;

if a  and 持仓判断 and n=0 then begin

   buy(holding=0,20%,marketr),pertrader;

   n:=1;

end

 

if b and not(a) and 持仓判断  and m=0 then begin

    buy(holding=0,10%,marketr),pertrader;

    m:=1;

end

 

if n=1 and c then buy(1,10%,marketr),pertrader;

if m=1 and c then buy(1,5%,marketr),pertrader;

 

if 平仓条件  and n=1 and holding>0 then begin

   sell.......;

   n:=0;

end

 

if 平仓条件  and m=1 and holding>0 then begin

   sellshort......;

   m:=0;

end


--  作者:fxrock4
--  发布时间:2016/1/29 16:01:45
--  
variable:n=0;
variable:m=0;
if kd  and HOLDING=0 and n=0 then begin
   buy(holding=0,20%,marketr)pertrader;
   n:=1;
end
 
if kd2 and not(kd1) and HOLDING=0  and m=0 then begin
    buy(holding=0,10%,marketr),pertrader;
    m:=1;
end
 
if n=1 and c then buy(1,10%,marketr),pertrader;
if m=1 and c then buy(1,5%,marketr),pertrader;
 
if pd  and n=1 and holding>0 then begin
   sell(PD ,100%,THISCLOSE);
   n:=0;
end
 
if pk  and m=1 and holding>0 then begin
   sellshort(PD ,100%,THISCLOSE);
   m:=0;
end
---------------还是信号不对。

--  作者:jinzhe
--  发布时间:2016/1/29 16:03:35
--  
举个例子
--  作者:fxrock4
--  发布时间:2016/1/29 16:11:57
--  
开多:BUY(KD  AND HOLDING=0,20%,MARKETR);          //开多信号
if holding>0 and kd and 条件C then buy(1,10%,market);//加仓
if holding>0 and kd and 条件D then buy(1,1%,market);
开多2:BUY(KD2  AND HOLDING=0,14%,MARKETR);          //开多信号2
if holding>0 and kd2 and 条件C then buy(1,5%,market);//加仓
if holding>0 and kd2 and 条件D then buy(1,0.5%,market);
平多:SELL(PD ,100%,THISCLOSE);                       //平多信号

开空:BUYSHORT(KK AND HOLDING=0,n%,MARKETR);     //开空信号
if holding<0 and 条件C then buyshort(1,10%,market);
if holding<0 and 条件D then buyshort(1,1%,market);
开空2:BUYSHORT(KK2 AND HOLDING=0,14%,MARKETR);     //开空信号2
if holding<0 and kk2 and 条件C then buyshort(1,5%,market);
if holding<0 and kk2 and 条件D then buyshort(1,0.5%,market);
=========================
当开多开空条件成立时,不再开多2和开空2
平空:SELLSHORT(PK ,100%,THISCLOSE);                 //平空信号

--  作者:fxrock4
--  发布时间:2016/1/29 16:13:02
--  
当开多开空条件成立时,不再开多2和开空2和加仓。