人人爽天天爽夜夜爽qc-人人爽天天爽夜夜爽曰-人人天天爱天天做天天摸-人人天天夜夜-色网站在线-色网站在线看

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

百度搜索

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

  • 咨詢內容:

    環境介紹:

    //運行周期:1分鐘

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

    //運行品種:IF1303

     

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

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

     

     

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

    藍色為測試的圖表交易系統:

    globalvariable:hold=drawnull;

    //以下為系統內容
    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;//這句放在信號穩定的地方

    drawtextex(1,1,800,0,'虛擬持倉為:'+numtostr(cc803555,0));//在圖表上輸入虛擬持倉以便監控
    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;

     

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

    圖表系統單獨運行,測試正常

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

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

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

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

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

     

     

     

  • 金字塔客服:

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

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

     

  • 用戶回復:

    同樣的交易系統,我也寫了一個后臺程序:

     

     

    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線,執行
    IF islastbar and  time<151000 then begin

     // 如果最后一根k線發生過開倉信號,則那一根k線不再交易
     if extgbdata('t1_enterbarpos') = barpos then begin
      goto continueline ;
     end
     
    //沒有持倉狀態
    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//沒有持倉狀態
        
    //持有倉位狀態
       //持有空頭
    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) ;

     

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

     

     

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

     

  • 網友回復:

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

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

    修改部分紅色顯示

     

    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值不穩定,故不能調用圖表的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編輯過]

 

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

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


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

相關文章

    沒有相關內容
主站蜘蛛池模板: 黄色免费一级 | 亚洲成a人片77788 | 一级特级aaaa毛片免费观看 | 97精品视频在线观看 | 女人牲交视频一级毛片 | 久久综合五月开心婷婷深深爱 | 久久有码中文字幕 | 久青草中文字幕精品视频 | 中文字幕免费在线播放 | 中文字幕日本不卡一二三区 | 黄色一级片在线看 | 国产丝袜视频在线观看 | 亚洲欧美日韩天堂在线观看 | 日本中文字幕永久在线 | 小明日韩在线看看永久区域 | 午夜网站入口 | 日韩免费中文字幕 | 男人的天堂免费视频 | 夜夜夜夜爽 | 中国一级毛片 | 黄色大片免费看 | 国产午夜毛片v一区二区三区 | 精品国产免费人成高清 | 亚洲国产中文字幕在线观看 | 中文一级国产特级毛片视频 | 久久99精品国产麻豆不卡 | 日韩欧美亚洲精品 | 国产精品免费一区二区三区四区 | 99视频在线看观免费 | 亚洲日本高清成人aⅴ片 | 成人三级在线播放 | 国产污污视频 | 天天射天天操天天 | 色噜噜久久 | 2020国产精品视频免费 | 免费人成在线观看网站 | 欧美日韩亚洲二区在线 | 亚洲国产精品日韩在线观看 | 欧美日一级 | 亚洲成人免费在线观看 | 一本大道香蕉大在线最新 |
网站统计