大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

您現(xiàn)在的位置:程序化交易>> 期貨公式>> 金字塔等>> 金字塔知識>>正文內容

后臺模板套入后的問題 [金字塔]

  • 咨詢內容:

    環(huán)境介紹:

    //運行周期:1分鐘

    //運行模式:固定時間間隔,1秒輪詢 

    //運行品種:IF1303

     

    會多個策略對改品種下單,希望各策略的開平倉獨立,每個策略管好自己的開平倉 

    系統(tǒng)很簡單,就是最高價突破均線平空開多,最低價突破平多開空,每根K線都只開平一次,開倉后當根K線后面的信號可以忽略

     

     

    利用火哥的模板http://www.weistock.com/bbs/dispbbs.asp?boardid=10&id=9112

    藍色為測試的圖表交易系統(tǒng):

    globalvariable:hold=drawnull;

    //以下為系統(tǒng)內容
    ss:=1; //手數
    //variable:myenterbars=0;

    maa:ema(c,10);
    tt1:=h>maa;
    tt2:=l<maa;
    //當開始沒有持倉
    if  holding=0 then begin
         if tt1 then  begin
             buy(1,ss,market)
             goto continueline;
         end
        
         if tt2 then begin
            buyshort(1,ss,market);
            goto continueline;
         end
    end

    if tt1 and  holding<0 and  enterbars>=0 then begin
         sellshort(1,ss,market);
         buy(1,ss,market);
         goto continueline;
    end

    if tt2 and  holding>0 and  enterbars>=0 then begin
         sell(1,ss,market);
         buyshort(1,ss,market);
         goto continueline;
    end

    continueline@ 資產:tasset,linethick0;
    aa-tt:if(tt1,1,if(tt2,-1,0)),nodraw;
    bb-holding:holding,nodraw;
    cc-enterbars:enterbars,nodraw;

    //以上為模型內容

     

    cc803555:=holding;//這句放在信號穩(wěn)定的地方

    drawtextex(1,1,800,0,'虛擬持倉為:'+numtostr(cc803555,0));//在圖表上輸入虛擬持倉以便監(jiān)控
    if not(islastbar) or workmode<>1 then exit;


    xiadan803555:=cc803555-hold;
    if xiadan803555>0.5 then begin
    cang:=min(xiadan803555,abs(hold));


    if hold<0 then begin
    tsellshort(1,cang,mkt,0,0,'803555'),allowrepeat;
    debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 平空 %.0f',cang);
    end
    cang:=xiadan803555+min(hold,0);


    if cang>0 then begin
    tbuy(1,cang,mkt,0,0,'803555'),allowrepeat;
    debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 開多 %.0f',cang);
    end
    end
    if xiadan803555<-0.5 then begin
    cang:=min(abs(xiadan803555),abs(hold));
    if hold>0 then begin
    tsell(1,cang,mkt,0,0,'803555'),allowrepeat;
    debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 平多 %.0f',cang);
    end


    cang:=abs(xiadan803555)-max(hold,0);
    if cang>0 then begin
    tbuyshort(1,cang,mkt,0,0,'803555'),allowrepeat;
    debugfile('d:\803555.txt',numtostr(hold,0)+' '+numtostr(cc803555,0)+' 開空 %.0f',cang);
    end
    end
    hold:=cc803555;

     

    運行環(huán)境:(1手單)1分鐘 IF1303 逐K模式  賬號為虛擬賬號

    圖表系統(tǒng)單獨運行,測試正常

    套入后臺模板后,有幾個問題:

    1)單賬號沒有持倉的時候,交易正常

    2)當我手動將賬號調成2手多頭2手空頭同時持有,再加載這個后臺系統(tǒng),系統(tǒng)開始只會把其中的一手空倉或者多倉做反手(就是系統(tǒng)一直都是持有4手單),總單量沒變

    3)之前在圖表加載的時候,一根K線只會執(zhí)行一次開平倉,但套入后套模板后,卻會在同一K線出現(xiàn)多次開平倉(不知道是不是因為模板里面的allowrepeat函數問題),

         請問是否將其去除就不會出現(xiàn)多次開平倉的問題?

     

     

     

  • 金字塔客服:

    2.今天1:30左右模擬交易服務器出了問題

    3.是的,allowrepeat允許指令在同一個周期內反復發(fā)出信號.

     

  • 用戶回復:

    同樣的交易系統(tǒng),我也寫了一個后臺程序:

     

     

    ss:=1; //手數
    extgbdataset('t1_position',0);
    //0表示沒有倉位,1表示持有多頭, -1表示持有空頭
    extgbdataset('t1_holding',0);
    //0表示沒有倉位,>0表示持有多頭, <0表示持有空頭
    extgbdataset('t1_enterbarpos',0);//記錄其開倉的K線

    maa:ema(c,10);
    bpk:=h>maa;
    spk:=l<maa;
    //非最后一根K線退出
    if not(islastbar) or workmode<>1 then exit;

    //如果當是最后一根k線,執(zhí)行
    IF islastbar and  time<151000 then begin

     // 如果最后一根k線發(fā)生過開倉信號,則那一根k線不再交易
     if extgbdata('t1_enterbarpos') = barpos then begin
      goto continueline ;
     end
     
    //沒有持倉狀態(tài)
    if extgbdata('t1_position')=0  and extgbdata('t1_holding')=0 then begin
         if  bpk then begin
           
            tbuy(1,ss,mkt);
            extgbdataset('t1_position',1);
            extgbdataset('t1_holding',ss);
            extgbdataset('t1_enterbarpos',barpos);
            goto continueline ;
           
          end

          if spk then begin
          
             tbuyshort(1,ss,mkt);
             extgbdataset('t1_position',-1);
             extgbdataset('t1_holding',-ss);
             extgbdataset('t1_enterbarpos',barpos);
             goto continueline ;
            
          end
    end//沒有持倉狀態(tài)
        
    //持有倉位狀態(tài)
       //持有空頭
    if bpk and extgbdata('t1_position')=-1   and  extgbdata('t1_holding')<0 then begin

           tsellshort(1,ss,mkt);
           tbuy(1,ss,mkt);
           extgbdataset('t1_position',1);
           extgbdataset('t1_holding',ss);
           extgbdataset('t1_enterbarpos',barpos);
           goto continueline ;
          
    end
        //持有多頭
    if spk and extgbdata('t1_position')=1    and  extgbdata('t1_holding')>0  then begin

            tsell(1,ss,mkt);
            tbuyshort(1,ss,mkt);
            extgbdataset('t1_position',-1);
            extgbdataset('t1_holding',-ss);
            extgbdataset('t1_enterbarpos',barpos);
            goto continueline ;
           
    end
    END//if  ISLASTBAR

    if  time>=151300 then begin

                 tsell(extgbdata('t1_holding')>0,ss,mkt);
                 tsellshort(extgbdata('t1_holding')<0,ss,mkt);
                 extgbdataset('t1_position',0);
                 extgbdataset('t1_holding',0);
                         
    end

    continueline@ 資產:tasset,linethick0;
    position:=extgbdata('t1_position');
    t1holding:=extgbdata('t1_holding');
    debugfile('d:\debug\803555.txt','position=%.0f' ,position) ;
    debugfile('d:\debug\803555.txt','t1holding=%.0f' ,t1holding) ;

     

    如果上模板不能很好執(zhí)行,不知道我這個能否可行,謝謝

     

     

    [此貼子已經被作者于2013-2-26 16:06:06編輯過]

     

  • 網友回復:

    藍色部分少做修改,供您參考

    樓主的公式,固定時間間隔,照1樓所寫,會造成信號閃爍,推薦將條件適當修改,以使信號穩(wěn)定,才能使用阿火的策略

    修改部分紅色顯示

     

    ss:=1; //手數
    //variable:myenterbars=0;

    maa:ref(ema(c,10),1);


    buycond:=h>maa;
    sellcond:=l<maa;

    if holding>0 and sellcond then sell(1,ss,market);
    if holding<0 and buycond then sellshort(1,ss,market);
    if holding=0 and buycond then buy(1,ss,market);
    if holding=0 and sellcond then buyshort(1,ss,market);

    [此貼子已經被作者于2013-2-28 11:04:22編輯過]

     

  • 網友回復:

    固定時間間隔,有信號就下單,信號閃爍情況下造成HOLDING值不穩(wěn)定,故不能調用圖表的HOLDING來控制倉位

     

    必須使用后臺程序化交易,

    對3樓的少做修改,供您參考

     

    全局變量使用注意事項:

    策略運行過程中,手動平倉進行干預,請到"工具--數據--全局變量"里,將對應的全局變量清0,否則會引起開平倉混亂

     

     

    //序列模式運行
    //t1_flag 0表示沒有倉位,1表示持有多頭,-1表示持有空頭

    ss:=1; //手數

    maa:ema(c,5);
    buycond:=h>maa;
    sellcond:=l<maa;

     

    //平多

    if extgbdata('t1_flag')>0 and sellcond then
      begin
      tsell(1,ss,mkt);
      extgbdataset('t1_flag',0);
      end

     

    //平空
    if extgbdata('t1_flag')<0 and buycond then
      begin
      tsellshort(1,ss,mkt);

      extgbdataset('t1_flag',0);
      end 

     

    //開多
    if extgbdata('t1_flag')=0 and buycond then
      begin
      tbuy(1,ss,mkt);
      extgbdataset('t1_flag',1);
      end

     

    //開空
    if extgbdata('t1_flag')=0 and sellcond then

        begin
        tbuyshort(1,ss,mkt);
        extgbdataset('t1_flag',-1);
        end

    [此貼子已經被作者于2013-3-5 13:39:41編輯過]

 

有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

可聯(lián)系技術人員 QQ: 262069696  點擊在線交流進行 有償 編寫!不貴!點擊查看價格!


【字體: 】【打印文章】【查看評論

相關文章

    沒有相關內容
主站蜘蛛池模板: 成人毛片在线观看 | 88国产经典欧美一区二区三区 | 国产亚洲日本人在线观看 | 99在线热视频只有精品免费 | 亚洲不卡视频在线观看 | 五月婷久久 | 亚州综合激情另类久久久 | 亚洲精品视频在线播放 | 日韩亚洲欧美在线爱色 | 情趣色视频网站 | 玖玖国产在线 | 中文字幕在线一区二区在线 | 4虎永免费最新永久免费地址 | 天天做天天爱夜夜爽毛片毛片 | 欧美jizzhd精品欧美另类 | 狠狠亚洲婷婷综合色香五 | 亚洲视频二区 | 久草青青 | 天堂精品视频 | 亚洲成年人视频 | 欧美成人日韩 | 国产视频不卡 | 日韩欧美在线视频 | 日本精品二区 | 亚洲欧美日韩一区二区 | 天天做天天添婷婷我也去 | 97免费在线 | a毛片免费看| 欧美成年黄网站色视频 | 一区二区在线精品免费视频 | 国产欧美日韩精品第二区 | 夜夜夜夜猛噜噜噜噜噜 | 青草视频在线观看免费资源 | 国产成人在线视频免费观看 | 狠狠狠地在啪线香蕉 | 午夜美女久久久久爽久久 | 一区二区三区在线免费视频 | 欧美日韩在线高清 | 奇米成人影视 | 亚洲综合色丁香麻豆 | 狠狠色丁香婷婷综合最新地址 |