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

前輩,麻煩幫我看看這個(gè)海龜代碼,謝謝 [MC]

  • 咨詢內(nèi)容: 我剛接觸MC不久,網(wǎng)上淘來一段Tradestation海龜策略代碼,導(dǎo)入MC后編譯不能通過。以下是代碼部分:

    vars: N(0),StopLoss(1),DV(0),BB(0),AccountBalance(0),DollarRisk(0),LTT(0),
    Tracker(0),LastTrade(0),HBP(0),LBP(0); input: InitialBalance(10000000);
    {/// Turtle 20-Day Breakout Replica //////////////////////////////////////}
    if marketposition = 0 then begin
    BB = 0;
    N = AvgTrueRange(20); DV = N*BigPointValue;
    AccountBalance = InitialBalance;
    DV = N * BigPointValue;
    {AccountBalance = InitialBalance + netprofit;}
    DollarRisk = AccountBalance * .01;
    LTT = IntPortion(DollarRisk/DV);
    StopLoss = 2 * DV * LTT;
    if LastTrade = -1 then begin
    buy LTT shares next bar highest(h,20) or higher;
    buy LTT shares next bar highest(h,20) + (0.5*N) or higher;
    buy LTT shares next bar highest(h,20) + (1.0*N) or higher;
    buy LTT shares next bar highest(h,20) + (1.5*N) or higher;
    Sell LTT shares next bar lowest(l,20) or lower;
    Sell LTT shares next bar lowest(l,20) - (0.5*N) or lower;
    Sell LTT shares next bar lowest(l,20) - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,20) - (1.5*N) or lower;
    end;
    if LastTrade = 1 then begin
    buy LTT shares next bar highest(h,55) or higher;
    buy LTT shares next bar highest(h,55) + (0.5*N) or higher;
    buy LTT shares next bar highest(h,55) + (1.0*N) or higher;
    buy LTT shares next bar highest(h,55) + (1.5*N) or higher;
    Sell LTT shares next bar lowest(l,55) or lower;
    Sell LTT shares next bar lowest(l,55) - (0.5*N) or lower;
    Sell LTT shares next bar lowest(l,55) - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,55) - (1.5*N) or lower;
    end;
    end;
    {// PREVIOUS TRADE TRACKER}
    if HBP = 0 and h > highest(h,19)[1] then begin
    Tracker = 1; HBP = h; LBP = 0;
    end;
    if LBP = 0 and l < lowest(l,19)[1] then begin
    Tracker = -1; LBP = l; HBP = 0;
    end;
    if Tracker = 1 then begin
    if l < HBP - (2*N) then LastTrade = -1;
    if h > HBP + (4*N) then LastTrade = 1;
    end;
    if Tracker = -1 then begin
    if h > LBP + (2*N) then LastTrade = -1;
    if l < LBP - (4*N) then LastTrade = 1;
    end;
    {// LONG 20 }
    if LastTrade = -1 and marketposition = 1 then begin
    BB = BB + 1;
    if currentcontracts = LTT then begin
    buy LTT shares next bar highest(h,20)[BB] + (0.5*N) or higher;
    buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
    buy LTT shares next bar highest(h,20)[BB]+ (1.5*N) or higher;
    end;
    if currentcontracts = LTT * 2 then begin
    buy LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
    buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
    end;
    if currentcontracts = LTT * 3 then
    buy LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
    end;
    {// LONG 55}
    if LastTrade = 1 and marketposition = 1 then begin
    BB = BB + 1;
    if currentcontracts = LTT then begin
    buy LTT shares next bar highest(h,55)[BB] + (0.5*N) or higher;
    buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
    buy LTT shares next bar highest(h,55)[BB]+ (1.5*N) or higher;
    end;
    if currentcontracts = LTT * 2 then begin
    buy LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
    buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
    end;
    if currentcontracts = LTT * 3 then
    buy LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
    end;
    ExitLong ("out-S") next bar lowest(l,10) or lower;
    {// SHORT 20 }
    if LastTrade = -1 and marketposition = -1 then begin
    BB = BB + 1;
    if currentcontracts = LTT then begin
    Sell LTT shares next bar lowest(l,20)[BB] - (0.5*N) or lower;
    Sell LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
    end;
    if currentcontracts = LTT * 2 then begin
    Sell LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
    end;
    if currentcontracts = LTT * 3 then
    Sell LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
    end;
    {// SHORT 55 }
    if LastTrade = 1 and marketposition = -1 then begin
    BB = BB + 1;
    if currentcontracts = LTT then begin
    Sell LTT shares next bar lowest(l,55)[BB] - (0.5*N) or lower;
    Sell LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
    end;
    if currentcontracts = LTT * 2 then begin
    Sell LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
    Sell LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
    end;
    if currentcontracts = LTT * 3 then
    Sell LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
    end;
    ExitShort ("out-B") next bar highest(h,10) or higher;
    {// STOPS}
    if currentcontracts = (2 * LTT) then StopLoss = DV * 3.5 * LTT;
    if currentcontracts = (3 * LTT) then StopLoss = DV * 4.5 * LTT;
    if currentcontracts = (4 * LTT) then StopLoss = DV * 5.0 * LTT;
    setstoploss (StopLoss);
    {// COMMENTARY}
    commentary ("LTT: ",LTT,Newline);
    commentary ("currentcontracts: ",currentcontracts,Newline);
    commentary ("StopLoss: ",StopLoss,Newline);
    commentary ("AccountBalance:",AccountBalance,NewLine);
    commentary ("LastTrade: ",LastTrade,NewLine);

    編譯時(shí)遇到問題,ExitShort 和 ExitLong 不能通過,這是兩個(gè)函數(shù)?是否這段代碼少了這個(gè)函數(shù)的內(nèi)容呢?我根據(jù)語法大概意思,用buytocover替換ExitLong,用sell替換ExitShort 。能夠編譯通過,但是圖表只有2個(gè)信號(hào),與海龜法則相去甚遠(yuǎn)。不知道是這段代碼不完整?還是Tradestation的程序在MC上需要做些修改才能使用呢?

     

  • MC技術(shù)部: 我們網(wǎng)站上找到一個(gè)海龜?shù)恼n程,老師講授的課程剛好就是這個(gè)代碼,可惜沒有完整版提供,我根據(jù)老師上課內(nèi)容對(duì)上面代碼做了些修改,但是圖表上還是沒有信號(hào)。不知道問題出在哪里?下面我把我修改的代碼附上,麻煩老師有時(shí)間幫我看下,謝謝

    [IntrabarOrderGeneration = True]
    input: InitialBalance(200000);
    vars: N(0),StopLoss(1),DV(0),BB(0),
                    AccountBalance(0),DollarRisk(0),system(0),
                    LTT(0),Tracker(0),LastTrade(0),HBP(0),LBP(0);
    {/// Turtle 20-Day Breakout Replica //////////////////////////////////////}
    if marketposition = 0 then begin
            BB = 0;
            N = AvgTrueRange(20);
            DV = N * BigPointValue;
            {AccountBalance = InitialBalance;}
            AccountBalance = InitialBalance + netprofit;
            DollarRisk = AccountBalance * 0.01;
            LTT = IntPortion(DollarRisk/DV/2);
            StopLoss = 2 * DV * LTT;
            if LastTrade = -1 then begin
                    buy ("b20-1") LTT shares next bar highest(h,20) or higher;
                    buy ("b20-2") LTT shares next bar highest(h,20) + (0.5*N) or higher;
                    buy ("b20-3") LTT shares next bar highest(h,20) + (1.0*N) or higher;
                    buy ("b20-4") LTT shares next bar highest(h,20) + (1.5*N) or higher;
                    Sell("s20-1") LTT shares next bar lowest(l,20) or lower;
                    Sell("s20-2") LTT shares next bar lowest(l,20) - (0.5*N) or lower;
                    Sell("s20-3") LTT shares next bar lowest(l,20) - (1.0*N) or lower;
                    Sell("s20-4") LTT shares next bar lowest(l,20) - (1.5*N) or lower;
                    system = 1;
                    end;
            if LastTrade = 1 then begin
                    buy ("b55-1") LTT shares next bar highest(h,55) or higher;
                    buy ("b55-2") LTT shares next bar highest(h,55) + (0.5*N) or higher;
                    buy ("b55-3") LTT shares next bar highest(h,55) + (1.0*N) or higher;
                    buy ("b55-4") LTT shares next bar highest(h,55) + (1.5*N) or higher;
                    Sell ("s55-1") LTT shares next bar lowest(l,55) or lower;
                    Sell ("s55-2") LTT shares next bar lowest(l,55) - (0.5*N) or lower;
                    Sell ("s55-3") LTT shares next bar lowest(l,55) - (1.0*N) or lower;
                    Sell ("s55-4") LTT shares next bar lowest(l,55) - (1.5*N) or lower;
                    system = 2;
                    end;
            end;
    {// PREVIOUS TRADE TRACKER}
    if HBP = 0 and h > highest(h,19)[1] then begin
            Tracker = 1; HBP = h; LBP = 0;
            end;
    if LBP = 0 and l < Lowest(l,19)[1] then begin
            Tracker = -1; LBP = l; HBP = 0;
            end;
    //if LBP = 0 and l  HBP + (4*N) then LastTrade = 1;
    //        end;
    if Tracker = 1 then begin
            if l < HBP - (2*N) then LastTrade = -1;
            if h > HBP + (4*N) then LastTrade = 1;
            end;
    if Tracker = -1 then begin
            if h > LBP + (2*N) then LastTrade = -1;
            if l < LBP - (4*N) then LastTrade = 1;
    end;
    {// LONG 20 }
    if LastTrade = -1 and marketposition = 1 then begin
            BB = BB + 1;
            if currentcontracts = LTT then begin
                    buy ("b20-2+") LTT shares next bar highest(h,20)[BB] + (0.5*N) or higher;
                    buy ("b20-3+")LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
                    buy ("b20-4+")LTT shares next bar highest(h,20)[BB]+ (1.5*N) or higher;
                    end;
            if currentcontracts = LTT * 2 then begin
                    buy ("bf20-3++") LTT shares next bar highest(h,20)[BB] + (1.0*N) or higher;
                    buy ("bf20-4++") LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
                    end;
            if currentcontracts = LTT * 3 then
                    buy ("bf20-4+++") LTT shares next bar highest(h,20)[BB] + (1.5*N) or higher;
                    end;
    {// LONG 55}
    if LastTrade = 1 and marketposition = 1 then begin
            BB = BB + 1;
            if currentcontracts = LTT then begin
                    buy ("b55-2+") LTT shares next bar highest(h,55)[BB] + (0.5*N) or higher;
                    buy ("b55-3+") LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
                    buy ("b55-4+") LTT shares next bar highest(h,55)[BB]+ (1.5*N) or higher;
                    end;
            if currentcontracts = LTT * 2 then begin
                    buy ("b55-3++") LTT shares next bar highest(h,55)[BB] + (1.0*N) or higher;
                    buy ("b55-4++")LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
                    end;
            if currentcontracts = LTT * 3 then
                    buy ("b55-4+++") LTT shares next bar highest(h,55)[BB] + (1.5*N) or higher;
                    end;
    sell("out-S") next bar lowest(l,10) or lower;
    {// SHORT 20 }
    if LastTrade = -1 and marketposition = -1 then begin
            BB = BB + 1;
            if currentcontracts = LTT then begin
                    SellShort ("s20-2+") LTT shares next bar lowest(l,20)[BB] - (0.5*N) or lower;
                    SellShort ("s20-3+") LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
                    SellShort ("s20-4+") LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
            end;
            if currentcontracts = LTT * 2 then begin
                    SellShort ("s20-3++") LTT shares next bar lowest(l,20)[BB] - (1.0*N) or lower;
                    SellShort ("s20-4++") LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
                    end;
            if currentcontracts = LTT * 3 then
                    SellShort ("s20-4+++") LTT shares next bar lowest(l,20)[BB] - (1.5*N) or lower;
                    end;
    {// SHORT 55 }
    if LastTrade = 1 and marketposition = -1 then begin
            BB = BB + 1;
            if currentcontracts = LTT then begin
                    SellShort ("s55-2+") LTT shares next bar lowest(l,55)[BB] - (0.5*N) or lower;
                    SellShort ("s55-3+") LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
                    SellShort ("s55-4+") LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
                    end;
            if currentcontracts = LTT * 2 then begin
                    SellShort ("s55-3++") LTT shares next bar lowest(l,55)[BB] - (1.0*N) or lower;
                    SellShort ("s55-4++") LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
                    end;
            if currentcontracts = LTT * 3 then
                    SellShort ("s55-4+++") LTT shares next bar lowest(l,55)[BB] - (1.5*N) or lower;
                    end;
    buytocover ("out-B") next bar highest(h,10) or higher;
    {// STOPS}
    if currentcontracts = (2 * LTT) then StopLoss = DV * 3.5 * LTT;
    if currentcontracts = (3 * LTT) then StopLoss = DV * 4.5 * LTT;
    if currentcontracts = (4 * LTT) then StopLoss = DV * 5.0 * LTT;
    setstoploss (StopLoss);
    {// COMMENTARY}
    commentary ("LTT: ",LTT,Newline);
    commentary ("currentcontracts: ",currentcontracts,Newline);
    commentary ("StopLoss: ",StopLoss,Newline);
    commentary ("AccountBalance:",AccountBalance,NewLine);
    commentary ("LastTrade: ",LastTrade,NewLine);

 

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

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


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

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 一二三四视频免费视频 | 丁香伊人五月综合激激激| 欧美性黑人极品hd| 午夜视频在线观看国产| 四虎在线成人免费网站| 天堂资源wwww在线看| 丹麦大白屁股hdxxxx| 欧美三级香港三级日本三级| 免费女人18毛片a级毛片视频| 连开二个同学嫩苞视频| 国产精品四虎在线观看免费| jazzjazz国产精品一区二区| 无码内射中文字幕岛国片| 亚洲av无码久久精品蜜桃| 激情偷乱人伦小说视频在线| 噼里啪啦完整高清观看视频| 黄色网站免费在线观看| 国产网站麻豆精品视频| www.av片| 成年午夜无码av片在线观看| 久久精品夜夜夜夜夜久久| 欧美日本一本线在线观看| 人人澡人人澡人人澡| 精品性高朝久久久久久久| 国产亚洲精品美女| 日本阿v精品视频在线观看| 国语自产偷拍精品视频偷拍| 一个色综合高清在线观看| 日本pissjapantv厕所自| 亚洲Av高清一区二区三区| 欧美老妇bbbwwbbww| 免费人成在线观看网站品爱网| 老司机67194精品线观看| 国产在线爱做人成小视频| 在线亚洲小视频| 在线不卡一区二区三区日韩| www.人人干| 慧静和一群狼好爽| 久久91综合国产91久久精品| 日韩一卡2卡3卡4卡| 亚洲av永久无码精品天堂久久|