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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 逐k线计算改成序列

   

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


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

主题:逐k线计算改成序列

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


加好友 发短信
等级:论坛游民 帖子:169 积分:0 威望:0 精华:0 注册:2016/8/28 16:11:16
逐k线计算改成序列  发帖心情 Post By:2016/11/21 11:49:06    Post IP:116.29.219.154[只看该作者]


逐k线计算改成序列,有问题吗?能显示资金,仓位?只能模拟调试后才能有没问题?


input:p(10,2,200,1);
input:avglen(30,5,100,5);
upperma:ema(high,avglen);
lowerma:ema(low,avglen);

//建立多头的进场条件
long:=open>upperma+mindiff;
if long then begin
tsellshort(tholding<0,0,mkt);
//sellshort(holding<0,0,limitr ,upperma+mindiff);
//sellshort(holding<0,0,marketr);
tbuy(tholding=0,p,mkt);
//buy(holding=0,p, limitr ,upperma+mindiff);
//buy(holding=0,p, marketr);
end
//建立空头的进场条件
short:=open<lowerma-mindiff;
if short then begin
tsell(tholding>0,0,mkt);
//sell(holding>0,0,limitr,lowerma-mindiff);
//sell(holding>0,0,marketr);
tbuyshort(tholding=0,p,mkt);
//buyshort(holding=0,p,limitr,lowerma-mindiff);
//buyshort(holding=0,p,marketr);
end

{持仓:tholding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0;}



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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/11/21 13:05:44    Post IP:116.231.212.45[只看该作者]

可以,这段代码里面没有必须要逐k线的函数,这段代码可以用序列计算


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游民 帖子:169 积分:0 威望:0 精华:0 注册:2016/8/28 16:11:16
  发帖心情 Post By:2016/11/21 14:42:47    Post IP:116.29.219.154[只看该作者]



      1.跨周期引用指标线,三个周期开平信号合成一起模板,改成序列计算提示似乎使用逐k线,有问题吗? 
      2 引用其它模块开平仓信号,用stkindi('','line.开仓条件',0,3)引用没信号,只能引用指标线吗?(如下:zline:stkindi('','line.line1',0,3);)
图片点击可在新窗口打开查看此主题相关图片如下:qq截图20161121142504.png
图片点击可在新窗口打开查看
input:cang1(10,0,10,1),cang2(10,0,10,1),cang3(10,0,10,1);
variable:cc1=0,cc2=0,cc3=0;
zh1:'614251';
pz1:'nioo';
a:=ref(close,1);
line:=ma(a,30);


if not(islastbar) or workmode<>1 then begin
      exit;
      goto continueline@  ;
   end
if islastbar then begin
   if cc1>0 and c<line then begin
    //pc:=min(max(holding,0),cang1);
    pc:=min(tbuyholdingex( zh1,pz1 ,0 ),cang1);
    kc:=cang1-pc;
    //if pc>0 then sell(1,pc,limitr,open-mindiff);
    if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
    //if kc>0 then buyshort(1,kc,limitr,open+mindiff);
    if kc>0 then tbuyshort(1,kc,mkt,0,zh1,pz1);
    cc1:=0;
   end
  if cc1<0 and c>line  then begin
   // pc:=min(abs(min(holding,0)),cang1);
    pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang1);
    kc:=cang1-pc;
    //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
    if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
   //if kc>0 then buy(1,kc,limitr,open+mindiff);
   if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
   cc1:=0;
  end
  if cc1=0 and c>line  then begin
    //pc:=min(abs(min(holding,0)),cang1);
    pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang1);
    kc:=cang1-pc;
    //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
    if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
    //if kc>0 then buy(1,kc,limitr,open+mindiff);
    if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
    cc1:=1;
   end
  if cc1=0 and c<line then begin
     //pc:=min(max(holding,0),cang1);
     pc:=min(tbuyholdingex( zh1,pz1 ,0 ),cang1);
     kc:=cang1-pc;
   // if pc>0 then sell(1,pc,limitr,open-mindiff);
     if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
    //if kc>0 then buyshort(1,kc,limitr,open-mindiff);
    if kc>0 then tbuyshort(1,kc,mkt,0,zh1,pz1);
     cc1:=-1;
    end

   zline:stkindi('','line.line1',0,3);
  if cc2>0 and c<zline then begin
    // pc:=min(max(holding,0),cang1);
    pc:=min(tbuyholdingex( zh1,pz1 ,0 ),cang2);
    kc:=cang2-pc;
    //if pc>0 then sell(1,pc,limitr,open-mindiff);
    if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
    //if kc>0 then buyshort(1,kc,limitr,open+mindiff);
    if kc>0 then tbuyshort(1,kc,mkt,0,zh1,pz1);
    cc2:=0;
   end
  if cc2<0 and c>zline  then begin
    //pc:=min(abs(min(holding,0)),cang1);
    pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang2);
    kc:=cang2-pc;
    //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
    if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
   //if kc>0 then buy(1,kc,limitr,open+mindiff);
   if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
   cc2:=0;
  end
  if cc2=0 and c>zline  then begin
    //pc:=min(abs(min(holding,0)),cang1);
    pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang2);
    kc:=cang2-pc;
    //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
    if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
    //if kc>0 then buy(1,kc,limitr,open+mindiff);
    if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
    cc2:=1;
   end
  if cc2=0 and c<line then begin
     //pc:=min(max(holding,0),cang1);
     pc:=min(tbuyholdingex( zh1,pz1 ,0 ),cang2);
     kc:=cang2-pc;
     //if pc>0 then sell(1,pc,limitr,open-mindiff);
     if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
     //if kc>0 then buyshort(1,kc,limitr,open-mindiff);
     if kc>0 then tbuyshort(1,kc,mkt,0,zh1,pz1);
     cc2:=-1;
    end
  

    zline1:stkindi('','line.line1',0,5);


    if cc3>0 and c<zline1 then begin
       //pc:=min(max(holding,0),cang3);
       pc:=min(tbuyholdingex( zh1,pz1 ,0 ),cang3);
       kc:=cang3-pc;
       //if pc>0 then sell(1,pc,limitr,open-mindiff);
       if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
       //if kc>0 then buy(1,kc,limitr,open-mindiff);
       if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
       cc3:=0;
      end
     if cc3<0 and c>zline1 then begin
        //pc:=min(abs(min(holding,0)),cang3);
        pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang3);
        kc:=cang3-pc;
        //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
        if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
        //if kc>0 then buy(1,kc,limitr,open+mindiff);
        if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
        cc3:=0;
       end
     if cc3=0 and c>zline1 then begin
        //pc:=min(abs(min(holding,0)),cang3);
        pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang3);
        kc:=cang3-pc;
        //if pc>0 then sellshort(1,pc,limitr,open+mindiff);
        if pc>0 then tsellshort(1,pc,mkt,0,zh1,pz1);
        //if kc>0 then buy(1,kc,limitr,open+mindiff);
        if kc>0 then tbuy(1,kc,mkt,0,zh1,pz1);
        cc3:=1;
       end
     if cc3=0 and c<zline1 then begin
       // pc:=min(max(holding,0),cang3);
        pc:=min(abs(tsellholdingex( zh1,pz1 ,0 )),cang3);
        kc:=cang3-pc;
        //if pc>0 then sell(1,pc,limitr,open-mindiff);
        if pc>0 then tsell(1,pc,mkt,0,zh1,pz1);
        //if kc>0 then buyshort(1,kc,limitr,open-mindiff);
        if kc>0 then tbuyshort(1,kc,mkt,0,zh1,pz1);
       cc3:=-1;
      end
end
     continueline@ 

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/11/21 14:53:57    Post IP:180.169.30.6[只看该作者]

因为使用图表全局变量variable的关系,所以改成适合后台的超全局变量globalvariable即可


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

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


加好友 发短信
等级:论坛游民 帖子:169 积分:0 威望:0 精华:0 注册:2016/8/28 16:11:16
  发帖心情 Post By:2016/11/21 15:32:38    Post IP:116.29.219.154[只看该作者]

   谢谢!改了正常。
  另外,可以直接其他模块开仓平仓信号吗?
  如:long :stkindi('','line.开仓信号',0,3);
       if long then buy(1,1,market0;

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2016/11/21 15:45:28    Post IP:180.169.30.6[只看该作者]

不能引用信号,只能引用触发信号的条件


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部