以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  slastbar编写前后对应?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=154228)

--  作者:系统使用者
--  发布时间:2017/5/26 13:13:11
--  slastbar编写前后对应?
//交易系统
temp_ll:=llv(l,2);
if buycond and not(islastbar) then
begin
   sellshort(holding<0,ss,marketr);
   buy(holding=0,ss,marketr);
   ll:=temp_ll;
end
bstop:=l<ll-1*MINDIFF;
 if enterbars>0 and bstop and holding>0 and not(islastbar) then sell(1,ss,marketr);//止损止盈,实时出场
 if h>valuewhen(bstop,hhv(fh,4))and bifx=1 and holding=0 and not(islastbar) then buy(1,ss,marketr);
 if sellcond and not(islastbar) and holding>0 then sell(1,ss,marketr);
 
temp_hh:=hhv(h,2);
if sellcond and not(islastbar) then
begin
   sell(holding>0,ss,marketr);
   buyshort(holding=0,ss,marketr);
   hh:=temp_hh;
end
sstop:=h>hh+1*MINDIFF;
 if enterbars>0 and sstop and holding<0 and not(islastbar) then sellshort(1,ss,marketr);
 if l<valuewhen(sstop,llv(fl,4)) and bifx=-1 and holding=0 and not(islastbar) then buyshort(1,ss,marketr);
 if buycond and not(islastbar) and holding<0 then sellshort(1,ss,marketr);
//自动恢复持仓功能
if islastbar and tholding2<>holding then
 begin 
  if barpos=EXTGBDATA(\'kai\')+1 then//开仓信号消失  平仓
  begin
  sell(tholding2>0,ss,marketr);
  sellshort(tholding2<0,ss,marketr);
  EXTGBDATASET( \'kai\',0);
 end
  
  if barpos=EXTGBDATA(\'ping\')+1 then//平仓信号消失  开仓恢复
  begin
  buy(holding>0,ss,marketr);
  buyshort(holding<0,ss,marketr);
  EXTGBDATASET( \'ping\',0);
  end    
 end
if holding>0 and sellcond and islastbar then 
begin
 sell(1,ss,marketr);
 EXTGBDATASET( \'ping\',BARPOS);
end
if holding<0 and buycond and islastbar then 
begin
 sellshort(1,ss,marketr);
 EXTGBDATASET( \'ping\',BARPOS);
end

--  作者:系统使用者
--  发布时间:2017/5/26 13:16:13
--  
temp_ll:=llv(l,2);
if buycond and not(islastbar) then
begin
   sellshort(holding<0,ss,marketr);
   buy(holding=0,ss,marketr);
   ll:=temp_ll;
end
bstop:=l<ll-1*MINDIFF;
 if enterbars>0 and bstop and holding>0 and not(islastbar) then sell(1,ss,marketr);//止损止盈,实时出场
 if h>valuewhen(bstop,hhv(fh,4))and bifx=1 and holding=0 and not(islastbar) then buy(1,ss,marketr);
 if sellcond and not(islastbar) and holding>0 then sell(1,ss,marketr);
与后面同步持仓(次周期交易),应该使用not(islastbar)?

--  作者:系统使用者
--  发布时间:2017/5/26 13:17:33
--  
走完K线模式
--  作者:FexTel
--  发布时间:2017/5/26 13:25:17
--  
NOT(ISLASTBAR)  //你这个只能用走完K线模式,固定时间间隔当前K线不会存在信号的。   
另外我看你止损止盈又是实时出场

你现在是要实现?

--  作者:系统使用者
--  发布时间:2017/5/26 13:47:33
--  
止损止盈又是实时出场
就是这里,改不改NOT(ISLASTBAR)


--  作者:yukizzc
--  发布时间:2017/5/26 13:55:16
--  

你2楼的代码是用来当前交易的段落,还是处理历史交易信号的

建议类似代码用户可以加上些注释来方便工作人员理解,毕竟直接读源代码也是一件累事


--  作者:系统使用者
--  发布时间:2017/5/26 14:14:39
--  
处理历史交易信号的
--  作者:系统使用者
--  发布时间:2017/5/26 14:15:42
--  
止损,实时出场
--  作者:系统使用者
--  发布时间:2017/5/26 14:16:54
--  
if enterbars>0 and bstop and holding>0 and not(islastbar) then sell(1,ss,marketr);//止损,实时出场
 if h>valuewhen(bstop,hhv(fh,4))and bifx=1 and holding=0 and not(islastbar) then buy(1,ss,marketr);//突破次周期交易
 if sellcond and not(islastbar) and holding>0 then sell(1,ss,marketr);//止盈次周期

--  作者:系统使用者
--  发布时间:2017/5/26 14:42:23
--  
//自动恢复持仓功能
if islastbar and tholding2<>holding then
 begin 
  if barpos=EXTGBDATA(\'kai\')+1 then//开仓信号消失  平仓
  begin
  sell(tholding2>0,ss,marketr);
  sellshort(tholding2<0,ss,marketr);
  EXTGBDATASET( \'kai\',0);
 end
  
  if barpos=EXTGBDATA(\'ping\')+1 then//平仓信号消失  开仓恢复
  begin
  buy(holding>0,ss,marketr);
  buyshort(holding<0,ss,marketr);
  EXTGBDATASET( \'ping\',0);
  end    
 end
if holding>0 and sellcond and islastbar then 
begin
 sell(1,ss,marketr);
 EXTGBDATASET( \'ping\',BARPOS);
end
if holding<0 and buycond and islastbar then 
begin
 sellshort(1,ss,marketr);
 EXTGBDATASET( \'ping\',BARPOS);
end

实盘不执行持仓同步