欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请问这个怎么写,大师们给看下。

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有4500人关注过本帖树形打印复制链接

主题:请问这个怎么写,大师们给看下。

帅哥哟,离线,有人找我吗?
masterxl
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:72 积分:299 威望:0 精华:0 注册:2010/7/19 22:09:00
请问这个怎么写,大师们给看下。  发帖心情 Post By:2012/6/6 19:32:29    Post IP:27.115.74.98[显示全部帖子]

一下内容实际执行的不一样,想要的结果是当前周期开仓后条件不成立(信号消失了),则立即恢复上一次交易信号的持仓,但是执行的结果不对,不仅不对,连开仓信号也不对。

给看看问题出在哪里。

bOpen:=false;

sopen:=false;

if QQ and SS=1 and T0 then begin
 
  if O>=AA2 and H>MAX(ref(High,1),ref(High,2)) then begin //第一种开仓买
  
   if L>AA1 then
   Buy(bOpen = false and barpos>2,Q,market);
    bOpen := True;
   
   if L<=AA1 and enterbars=0  then//达到这个条件后立刻平仓
   
   Sell(holding>0,Q,market);
  
   bOpen := False; 
  end 
  
 
  
  if O<AA2 and H>AA3 then begin
  
   if L>ref(Low,1) then
   
        Buy(bopen=false,Q,market);
        bOpen := True;
   
   if L<=ref(Low,1) and enterbars=0 then//达到这个条件后立刻平仓
   
    
    Sell(holding>0,Q,market);
    
    bOpen := False;
   
  end
end
 
 //卖开仓
if QQ and XX=1 and T0 then begin
 
  if O>=AA2 and L<AA1 then begin //卖开
  
   if H<ref(high,1) then
   
    buyShort(sopen=false,Q,market);
    sOpen := True;
   
   if H>=ref(high,1) and enterbars=0 then //达到这个条件后立刻平仓
   
    sellshort(holding<0,Q,market);
    sOpen := False;
   
  end
  
  if O<AA2 and L<MIN(ref(Low,1),ref(Low,2)) then begin //卖开
  
   if H<AA3 then   
    
    buyShort(sopen=false,Q,market);
    sOpen := True;
   
   if H>=AA3  and enterbars=0 then //达到这个条件后立刻平仓
   
    
    buyshort(holding<0,Q,market);
    sOpen := False;
   
    end
end

 
//买平仓 
if sopen=true then begin

 if JZ or TT then 
 
  sellshort(sopen=true,Q,market);
  sOpen := False;
 
 if SS=1 then begin
 
  if O>=AA2 and H>ref(High,1) then begin
  
   if L>AA1 then
   
    
    sellshort(sopen=true,Q,market);
    sOpen := False;
   
   if L<=AA1 and type(1)=3   then//达到这个条件立刻恢复持仓
   
    
    buyShort(holding=0,Q,market);
    sOpen := True;
    
   
  end
  if O<AA2 and  H>AA3 then begin
  
   if L>ref(Low,1) then
   
    //BPPrice = Q_BidPrice+Y;
    sellshort(sopen=true,Q,market);
    sOpen := False;
   
   if L<=ref(Low,1) and type(1)=3  then //达到这个条件立刻恢复持仓
   
    
    buyShort(holding=0,Q,market);
     sOpen := True;
  end
end

end  
//卖平仓
if bopen=true then begin

 if JD or TT then
 
  
  Sell(bopen=true,Q,market);
  bOpen := False;
 
 if XX=1 then begin
   if O<AA2 and L<ref(Low,1) then begin
   if H<AA3 then
    Sell(bopen=true,Q,market);
    bOpen := False;
   
   if H>=AA3 and type(1)=1 then//达到这个条件立刻恢复持仓   
    
    Buy(holding=0,Q,market);
    bOpen := True;
   
   end
  if O>=AA2  and L<AA1 then begin
  
   if H<ref(High,1) then
   
    
    Sell(bopen=true,Q,market);
   
    bOpen := False;
   
   if H>=ref(High,1) and type(1)=1 then //达到这个条件立刻恢复持仓   
    
    Buy(holding=0,Q,market);
    bOpen := True;
   
  end
end
end;


 回到顶部
帅哥哟,离线,有人找我吗?
masterxl
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:72 积分:299 威望:0 精华:0 注册:2010/7/19 22:09:00
  发帖心情 Post By:2012/6/7 6:23:17    Post IP:114.92.76.140[显示全部帖子]

我在表述清楚一点吧

K1  and C>O//买开仓条件

K2 and C<O//卖开仓条件

S1 and C<O //平多仓条件

B1 and C>O //平空仓条件

 

要达到的结果如果K1满足且C>o则买入,否则一旦C<=O则平仓并恢复持仓;同样,如果K2满足且C<O则卖出开仓,否则一旦C>=O就平仓并恢复持仓;

如果S1满足且C<O,就平多,否则一旦C>=O就恢复持仓,如果B1满足且C>O就平空,否则一旦C<=O就恢复持仓。


 回到顶部
帅哥哟,离线,有人找我吗?
masterxl
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:72 积分:299 威望:0 精华:0 注册:2010/7/19 22:09:00
  发帖心情 Post By:2012/6/7 12:15:05    Post IP:27.115.74.98[显示全部帖子]

就是恢复上一次原有持仓

比如均线交叉系统,盘中肯定有交叉后又不成功的,那么当交叉后平反手的仓位在,交叉信号消失后,应该恢复原来的仓位。

 

如果原来是金叉,现在死叉成立,就平多做空,随着行情的发展死叉消失,那么平多做空就不成立,这样就需要把现在的空单平掉,并迅速恢复原来的多单仓位。这样说可说明白了?


 回到顶部
帅哥哟,离线,有人找我吗?
masterxl
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:72 积分:299 威望:0 精华:0 注册:2010/7/19 22:09:00
  发帖心情 Post By:2012/6/7 12:18:22    Post IP:27.115.74.98[显示全部帖子]

其实就是有些软件里面的“全自动交易信号消失后,自动恢复持仓”,这个和“信号消失后次周期恢复持仓”或者“当前K线走完恢复持仓”差别还是很大的

 回到顶部