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

加入交易次數(shù)限制后結(jié)果異常 [金字塔]

  • 咨詢內(nèi)容:

    早盤突破系統(tǒng),1分鐘上測(cè)試2年,

    剛開始寫完交易次數(shù)是1700多;后來(lái)添加了一個(gè)每天只能交易一手的條件,結(jié)果交易次數(shù)只有3次了!

    添加了交易次數(shù)限制的代碼如下,是我寫的邏輯出錯(cuò)了嗎?

     

    input:T(30,5,60,5),
    SS(1,1,10,1),
    U(1,1,10,1),
    D(1,1,10,1),
    CS(1,1,5,1);//交易次數(shù)限制
    VARIABLE:NUM=0;//統(tǒng)計(jì)開倉(cāng)動(dòng)作

     

    n:=barslast(date<>ref(date,1))+1;//開盤以來(lái)的K線數(shù)量
    hh:=hhv(high,n);//開盤以來(lái)的高價(jià)
    H30:=valuewhen(time>=opentime(1) and time<=opentime(1)+T*100,hh);//30分鐘內(nèi)的高價(jià)
    ll:=llv(low,n);//開盤以來(lái)的低價(jià)
    L30:=valuewhen(time>=opentime(1) and time<=opentime(1)+T*100,ll);//30分鐘內(nèi)的低價(jià)
    上軌:H30+U*MINDIFF,linethick2;
    下軌:L30-D*MINDIFF,linethick2;
    buycond:=cross(high,上軌);//做多條件
    buyshortcond:=cross(下軌,low);//做空條件
    buyprice:=max(open,上軌)+1*mindiff;//開多價(jià)格
    buyshortprice:=min(open,下軌)-1*mindiff;//開空價(jià)格

     

    stopbuy:max(valuewhen(n=1,open),ref(high,1)*(1-0.5/100)),linedot;//多頭止損價(jià)位

    stopshort:min(valuewhen(n=1,open),ref(low,1)*(1-0.5/100)),linedot;//空頭止損價(jià)位
    sellcond:=cross(stopbuy,low);//平多條件
    sellshortcond:=cross(high,stopshort);//平空條件
    sellprice:=min(open,stopbuy)-1*mindiff;//平多價(jià)格
    sellshortprice:=max(open,stopshort)+1*mindiff;//平空價(jià)格


    entertime:=time>opentime(1)+T*100 and time<closetime(0)-10*100;//入場(chǎng)交易時(shí)間
    exittime:=time>=closetime(0)-10*100;//平倉(cāng)離場(chǎng)時(shí)間

     

    if entertime and holding=0 and num<CS then  {開倉(cāng)入場(chǎng)}
    begin 
     if buycond then
        BEGIN
        buy(1,ss,limitr,buyprice);
        NUM:=NUM+1;
        END
     else if buyshortcond then
        BEGIN
        buyshort(1,ss,limitr,buyshortprice);
        NUM:=NUM+1;
        END
    end

     

    if enterbars>1 and holding<>0 then {止損離場(chǎng)}
    begin
     if holding>0 and sellcond then
        sell(1,ss,limitr,sellprice);
     else if holding<0 and sellshortcond then
        sellshort(1,ss,limitr,sellshortprice);
    end

     

    if exittime and holding<>0 then  {收盤平倉(cāng)}
    begin
      sell(holding>0,ss,limitr,open-1*mindiff);
      sellshort(holding<0,ss,limitr,open+1*mindiff);
      NUM:=0;
    end

     

    持倉(cāng):holding,linethick0;
    凈利潤(rùn):netprofit,linethick0;
    資產(chǎn):asset,linethick0;
    資金:cash(0),linethick0;


     
     

     

     

     

     

     

     

     

     

     

  • 金字塔客服: 并且檢查了一下圖表,本來(lái)當(dāng)天是數(shù)據(jù)是滿足交易條件的,卻沒有顯示也沒有執(zhí)行交易信號(hào)。

     

  • 用戶回復(fù):

    if exittime and holding<>0 then  {收盤平倉(cāng)}
    begin
      sell(holding>0,ss,limitr,open-1*mindiff);
      sellshort(holding<0,ss,limitr,open+1*mindiff);
      NUM:=0;
    end

     

    改成

     

    if exittime and holding<>0 then  {收盤平倉(cāng)}
    begin
      sell(holding>0,ss,limitr,open-1*mindiff);
      sellshort(holding<0,ss,limitr,open+1*mindiff);
    end

    if exittime then   NUM:=0;

     

  • 網(wǎng)友回復(fù):

    試了一下,的確糾正過(guò)來(lái)了謝謝、、

 

有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 511411198  點(diǎn)擊這里給我發(fā)消息進(jìn)行 有償 編寫!不貴!點(diǎn)擊查看價(jià)格!


【字體: 】【打印文章】【查看評(píng)論

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 欧美日韩精品久久久免费观看| 黄色片在线播放| 成年人在线网站| 亚洲免费人成在线视频观看| 精品国产免费一区二区三区 | 精品国产人成亚洲区| 国产成人精品久久亚洲高清不卡| 99久久人妻无码精品系列蜜桃| 成年女人毛片免费视频| 五月丁香六月综合av| 波多野结衣系列无限发射| 啊灬啊灬啊灬快好深用力免费| 国产黑丝袜在线| 国产美女精品久久久久久久免费| 中文字幕一区二区三区四区 | 免费一区二区视频| 色综合久久天天影视网| 国产最猛性xxxxxx69交| 91精品国产三级在线观看| 姚瑶小说穿越到古代免费阅读下载| 久久午夜国产片| 欧美一区二区福利视频| 亚洲精品无码久久毛片波多野吉衣| 综合亚洲伊人午夜网| 国产在线不卡免费播放| 两个人看的视频播放www| 在线黄视频网站| 一区二区手机视频| 无码中文字幕日韩专区| 久久精品亚洲综合| 欧洲精品99毛片免费高清观看| 亚洲欧美综合国产不卡| 相泽南亚洲一区二区在线播放| 国产99视频免费精品是看6| 高潮毛片无遮挡高清免费| 国产精品久久久久久久| 92午夜少妇极品福利无码电影| 小东西几天没做怎么这么多水 | 午夜精品久久久久久| 西西人体www高清大胆视频| 国产成人麻豆tv在线观看|