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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 策略信号混乱的问题

   

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


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

主题:策略信号混乱的问题

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


加好友 发短信
等级:论坛游侠 帖子:117 积分:0 威望:0 精华:0 注册:2019/1/18 14:44:34
策略信号混乱的问题  发帖心情 Post By:2019/3/14 16:06:48    Post IP:180.169.30.6[只看该作者]

input:initialstop(20,10,60,10);
input:breakvenstop(20,10,60,10);
input:trailingstop(30,10,60,10);
input:money(2,1,10,1);
variable:stopline:=0;

begin
 
//predayhigh:=callstock(stklabel,vthigh,6,-1);//昨高
//predaylow:=callstock(stklabel,vtlow,6,-1);//昨低
//predayopen:=callstock(stklabel,vtopen,6,0);//昨收
//上轨:昨高;
//下轨:昨低;
//手数:=SS;

dist1:=barslast(day <> ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayopen:= ref(open,dist1-1);

entrytime:=time>=0916000 and time<=144500;
exittime:time>=150000;

initialstopnum:=mindiff*initialstop;
breakvenstopnum:=mindiff*breakvenstop;
 trailingstopnum:=mindiff*trailingstop;
marginratio:=18/100;  
 
end
  
if holding=0 then begin
 if predayopen<predayhigh and entrytime and high>=predayhigh+mindiff then
 myentryprice:=max(open,predayhigh+mindiff);
 mycash:=cash(0);
 lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
 lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
 lots:=min(lots1,lots2);
  buy(1,lots,limitr,myentryprice);
 stopline:=0;
 end 
 
 if holding=0 then begin  
  if predayopen>predaylow and entrytime and low<=predaylow - mindiff then
   myentryprice:=max(open,predayhigh-mindiff);
  mycash:=cash(0);
  lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
   lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
    BUYSHORT(1,lots,limitr,myentryprice);
 stopline:=0;
end 

if holding>0 then begin
 costprice:=enterprice+mindiff;
 
 if exittime then
 sell(1,holding,limitr,open);
end    
 if stopline>0 and low<=stopline then
 sell(1,holding,limitr,min(open,stopline));
 
 if stopline=0 then begin
  stopline:=enterprice-initialstopnum;
    
    if stopline<costprice and high- breakvenstopnum>=costprice then
         stopline:=costprice;
   
    if stopline>=costprice and high-trailingstopnum>=stopline then
        stopline:=high-trailingstopnum;
  end
 
 if holding<0 then begin
 costprice:=enterprice-mindiff;
  
 if exittime then
 sellshort(1,holding,limitr,open);
 
 if stopline>0 and high>=stopline then
 sellshort(1,holding,limitr,max(open,stopline));
 
 if stopline=0 then
  stopline:=enterprice+initialstopnum;
   
    if stopline>costprice and low+breakvenstopnum<=costprice then
    stopline:=costprice;
   
    if stopline<costprice and low+trailingstopnum<=stopline then
        stopline:=low+trailingstopnum;
           
    end  


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


加好友 发短信
等级:论坛游侠 帖子:117 积分:0 威望:0 精华:0 注册:2019/1/18 14:44:34
  发帖心情 Post By:2019/3/14 16:10:29    Post IP:106.87.47.63[只看该作者]

老师,我这个策略信号乱了,我不知道是哪的原因,帮我看一下,谢谢

input:initialstop(20,10,60,10);
input:breakvenstop(20,10,60,10);
input:trailingstop(30,10,60,10);
input:money(2,1,10,1);
variable:stopline:=0;

begin
 
//predayhigh:=callstock(stklabel,vthigh,6,-1);//昨高
//predaylow:=callstock(stklabel,vtlow,6,-1);//昨低
//predayopen:=callstock(stklabel,vtopen,6,0);//昨收
//上轨:昨高;
//下轨:昨低;
//手数:=SS;

dist1:=barslast(day <> ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayopen:= ref(open,dist1-1);

entrytime:=time>=0916000 and time<=144500;
exittime:time>=150000;

initialstopnum:=mindiff*initialstop;
breakvenstopnum:=mindiff*breakvenstop;
 trailingstopnum:=mindiff*trailingstop;
marginratio:=18/100;  
 
end
  
if holding=0 then begin
 if predayopen<predayhigh and entrytime and high>=predayhigh+mindiff then
 myentryprice:=max(open,predayhigh+mindiff);
 mycash:=cash(0);
 lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
 lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
 lots:=min(lots1,lots2);
  buy(1,lots,limitr,myentryprice);
 stopline:=0;
 end 
 
 if holding=0 then begin  
  if predayopen>predaylow and entrytime and low<=predaylow - mindiff then
   myentryprice:=max(open,predayhigh-mindiff);
  mycash:=cash(0);
  lots1:=intpart(mycash/(myentryprice*multiplier*marginratio));
   lots2:=intpart((mycash*money/100)/(initialstopnum*multiplier));
   lots:=min(lots1,lots2);
    BUYSHORT(1,lots,limitr,myentryprice);
 stopline:=0;
end 

if holding>0 then begin
 costprice:=enterprice+mindiff;
 
 if exittime then
 sell(1,holding,limitr,open);
end    
 if stopline>0 and low<=stopline then
 sell(1,holding,limitr,min(open,stopline));
 
 if stopline=0 then begin
  stopline:=enterprice-initialstopnum;
    
    if stopline<costprice and high- breakvenstopnum>=costprice then
         stopline:=costprice;
   
    if stopline>=costprice and high-trailingstopnum>=stopline then
        stopline:=high-trailingstopnum;
  end
 
 if holding<0 then begin
 costprice:=enterprice-mindiff;
  
 if exittime then
 sellshort(1,holding,limitr,open);
 
 if stopline>0 and high>=stopline then
 sellshort(1,holding,limitr,max(open,stopline));
 
 if stopline=0 then
  stopline:=enterprice+initialstopnum;
   
    if stopline>costprice and low+breakvenstopnum<=costprice then
    stopline:=costprice;
   
    if stopline<costprice and low+trailingstopnum<=stopline then
        stopline:=low+trailingstopnum;
           
    end  



图片点击可在新窗口打开查看此主题相关图片如下:52.png
图片点击可在新窗口打开查看

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/3/14 16:17:46    Post IP:180.169.30.6[只看该作者]

 开仓价格超出下单K的范畴,所以都会显示成白色箭头。
建议调整价格或者在开平仓语句后面加一个IGNORECHECKPRICE:
buy(...),IGNORECHECKPRICE


命数如织,当如磐石。
 回到顶部
帅哥哟,离线,有人找我吗?
天天涨停
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:117 积分:0 威望:0 精华:0 注册:2019/1/18 14:44:34
  发帖心情 Post By:2019/3/14 16:26:38    Post IP:106.87.47.63[只看该作者]

老师,我加进去了,白色的箭头没有了,但没有任何信号。这个策略是根据视频教程讲的菲阿里四价策略记录的笔记,为什么不执行的,我弄不了。


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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/3/14 16:56:19    Post IP:180.169.30.6[只看该作者]

 根据报错是下单参数问题。我输出了下单手数变量,是下单参数计算出来的结果太大。实际资金根本不足以下那么多手数。


命数如织,当如磐石。
 回到顶部