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

虧三次加倉,盈三次減倉軟件難實(shí)現(xiàn)嗎? [金字塔]

  • 咨詢內(nèi)容: 下面是突破20日高低點(diǎn)策略,想實(shí)現(xiàn)連續(xù)盈三次后減倉,直到連續(xù)虧三次后恢復(fù)初始倉位,老師修改二次也不行,老樣回測倉位錯(cuò)亂,軟件難實(shí)現(xiàn)還是寫法有錯(cuò)?input :k(20,5,30,1) input:avglen(30,10,100,5);input : atrlen(20,5,30,1) ;input : ss(2,1,1000,1) ;
    //聲明變量nt := 1 ;   //調(diào)試信息帶時(shí)間戳buyorderthisbar := 0 ;   //當(dāng)前bar有過交易variable : _debug = 1 ;   //是否輸出前臺交易指令variable : turtleunits=0 ;   //交易單位variable : myentryprice1=0; variable : myentryprice2=0; variable : myexitprice=0;variable : n=0;variable : m=0;variable : yk=0; //準(zhǔn)備需要計(jì)算的變量zhh:ref(high,k);zll:ref(low,k);kqls:=enterbars+1;khh:=hhv(high,kqls);kll:=llv(low,kqls);
    avgtr :=ref(ma(tr,atrlen),1);
    //開始執(zhí)行時(shí) 初始化數(shù)據(jù)if barpos=1 then begin   position :=0 ;   posnum:=ss; end
    //如果當(dāng)前是沒有持倉的狀態(tài)if position=0 and  barpos>20 and h>l then begin    //建立多頭進(jìn)場條件   long:=high>=zhh ;   //多頭進(jìn)場   if long  and holding=0  then begin   myentryprice1 :=if(open>zhh+0.2 ,open+0.6 ,zhh+0.6);   buy( _debug,posnum,limitr,myentryprice1);   jqsh:=1;      position := 1 ;   turtleunits := 1 ;     // n:= avgtr ;   buyorderthisbar := 1;     end       //建立空頭進(jìn)場條件   short:=low<=zll ;   //空頭進(jìn)場   if short and position=0 and holding=0 then begin      myentryprice2:= if(open<zll-0.2 ,open-0.6 ,zll-0.6) ;   buyshort( _debug,posnum,limitr,myentryprice2);   jqsh:=1;   position := -1 ;   turtleunits := 1 ;   //n := avgtr ;   buyorderthisbar := 1;
        end end   
    //如果當(dāng)前持有多頭倉位的狀態(tài)
    if position=1 and barpos>20 and h>l then begin
       //多頭加倉條件     {while (close>myentryprice+0.5*n) and turtleunits<4 and jqsh=1 do begin   myentryprice := if(open>myentryprice+0.5*n ,open+0.6 ,myentryprice+0.5*n+0.6 ) ;   myentryprice:= ceiling(myentryprice/mindiff)*mindiff ;      buy( _debug, posnum, limitr,myentryprice );   turtleunits := turtleunits+1 ;   buyorderthisbar := 1;   end }     //建立多頭離場條件   longx1 := low<zll-mindiff;      myexitprice:=zll-mindiff;     if longx1 and buyorderthisbar=0 and holding>0 then begin   myexitprice := if(open<myexitprice-0.2 ,open-0.6 ,myexitprice-0.6) ;      sell( _debug ,0,limitr,myexitprice);   position := 0 ;   turtleunits := 0 ;   yk:=myexitprice- myentryprice2;      if yk>0 then begin          n:=0;         m:=m+1;         end               if yk<0   then begin         n:=n+1;         m:=0;        end         // if n>=3 then posnum:=ss; end      //  if m>=3 then posnum:=0.5*ss;       //建立多頭止損條件   longx2 := low<(khh-2*n);    if longx2 and position=1 and buyorderthisbar=0 and holding>0 then begin   myexitprice := if(open<khh-2*n ,open-0.6 ,khh-2*n-0.6) ;      myexitprice := floor(myexitprice/mindiff)*mindiff ;      sell( _debug ,0,limitr,myexitprice);   position := 0 ;   turtleunits := 0 ;   yk:=myexitprice- myentryprice2;      if yk>0 then begin     n:=0;     m:=m+1;         end      if yk<0   then begin         n:=n+1;         m:=0;        end          end   end
    //如果當(dāng)前持有空頭倉位的狀態(tài)
    if position = -1 and barpos>20 and h>l then begin
       //空頭加倉條件     {while (close<myentryprice-0.5*n) and turtleunits<4 and jqsh=1 do begin   myentryprice := if(open<myentryprice-0.5*n ,open-0.6 ,myentryprice-0.5*n-0.6 ) ;      kkj := floor(myentryprice/mindiff)*mindiff ;      buyshort( _debug,posnum, limitr,myentryprice );   turtleunits := turtleunits+1 ;   buyorderthisbar := 1;   end }   
       //建立空頭離場條件    shortx1 :=  high>zhh+mindiff;        myexitprice:=zhh+mindiff;    if shortx1 and buyorderthisbar=0 and holding<0 then begin   myexitprice := if(open>myexitprice,open+0.6, myexitprice+0.6);      sellshort( _debug,0,limitr,myexitprice);   position := 0 ;   turtleunits := 0 ;        yk:=myentryprice2-myexitprice;         if yk>0 then begin          n:=0;         m:=m+1;        end      if yk<0  then begin         n:=n+1;         m:=0;         end         //if n>=3 then posnum:=ss;         //if m>=3 then posnum:=0.5*ss;          end 
       //建立空頭止損條件   shortx2 := high>kll+2*n ;    if shortx2 and position = -1 and buyorderthisbar=0 and holding<0 then begin   myexitprice:= if(open>kll+2*n ,open+0.6 ,kll+2*n+0.6) ;      myexitprice := ceiling(myexitprice/mindiff)*mindiff ;      sellshort( _debug,0,limitr,myexitprice);   position := 0 ;   turtleunits := 0 ;   yk:=myentryprice2-myexitprice;         if yk>0   then begin         n:=0;        m:=m+1;       end      if yk<0   then begin        n:=n+1;        m:=0;       end      // if n>=3 then posnum:=ss;       //if m>=3 then posnum:=0.5*ss;       end end           if n>=3 and ref(n,1)=2 then posnum:=ss;if m>=3 and ref(m,1)=2 then posnum:=0.5*ss;     

     

  • 金字塔客服:

    不要重復(fù)發(fā)帖,在之前那個(gè)帖子里面進(jìn)行處理

 

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

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


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

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 日本免费电影在线观看| 男人添女人p免费视频动态图| 国产黄色片在线观看| 久久se精品一区二区国产| 欧美在线精品一区二区在线观看 | 欧美日韩小视频| 又粗又大又猛又爽免费视频| 成人免费黄网站| 国产色无码精品视频国产| 一区二区三区视频观看| 日本按摩高潮a级中文片| 亚洲国产欧美无圣光一区| 男女做羞羞的事漫画| 国产一区二区三区在线影院| 欧美大片一区二区| 国产高清在线a视频大全| 一a一片一级一片啪啪| 无码av专区丝袜专区| 久草资源福利站| 欧美性猛交xxxx乱大交极品| 亚洲黄色在线看| 精品熟人妻一区二区三区四区不卡 | 车车好快的车车流水网站入口| 国产精品乱码在线观看| 99久久99久久精品国产片| 小泽玛利亚番号| 丰满人妻被黑人中出849| 日韩欧美国产精品| 亚洲人成在线播放网站岛国| 毛片在线高清免费观看| 免费人成网站在线播放| 美女久久久久久| 国产亚洲精品拍拍拍拍拍| 国产v亚洲v天堂a无| 国产精品天天干| 91精品国产入口| 大陆少妇xxxx做受| а√天堂中文在线官网| 成人免费ā片在线观看| 中文精品字幕电影在线播放视频| 日本黄色激情片|