您现在的位置:程序化交易>> 期货公式>> 文华财经>> 文华财经知识>>正文内容

[求助]请老师帮忙翻译一下 [文华财经]

  • 咨询内容:  请老师帮忙翻译2个开拓者TB的策略:

    策略一: ParamsNumeric shares(1);Numeric Params3(2);Numeric Params4(3);Numeric Params2(0.70);Numeric Params1(1.30);Numeric Params5(9.15);VarsNumeric i(0); Numeric n(0);Numeric var1(0);Numeric var2(0);Numeric var3(0);Numeric var4(0);Numeric var5(0);Numeric var6(0);NumericSeries var7(0);NumericSeries var8(0);NumericSeries var9(0);NumericSeries var10(0);Numeric var11(0);Numeric var12(0);Numeric var13(0);Numeric var14(0);
    Begin If(CurrentBar == 0 || Date != Date[1]) { var7 = 1; var8 = High; var9 = Low; }Else { var7 = var7 + 1; If(High > var8) var8 = High; If(Low < var9) var9 = Low; } var10 = Close; For i = 1 to Params3 { If(i == 1) { n = var7; var11 = var8[n]; var12 = var9[n]; var13 = var10[n]; var14 = var10[n]; }Else { n = n + var7[n]; } If(var8[n] > var11) var11 = var8[n]; If(var9[n] < var12) var12 = var9[n]; If(var10[n] > var13) var13 = var10[n]; If(var10[n] < var14) var14 = var10[n]; } var1 = Max(var11 - var14, var13 - var12); For i = 1 to Params4 { If(i == 1) { n = var7; var11 = var8[n]; var12 = var9[n]; var13 = var10[n]; var14 = var10[n]; }Else { n = n + var7[n]; } If(var8[n] > var11) var11 = var8[n]; If(var9[n] < var12) var12 = var9[n]; If(var10[n] > var13) var13 = var10[n]; If(var10[n] < var14) var14 = var10[n]; } var2 = Max(var11 - var14, var13 - var12); var3 = OpenD(0) + var1 * Params1; var4 = OpenD(0) - var2 * Params2; var5 = PriceScale * MinMove;
    If(Time < Params5 / 100) Return; If(MarketPosition  != 1) { If(High >= var3) { Buy(shares, Max(Open, var3)); Return; } } If(MarketPosition != -1) { If(Low <= var4) { SellShort(shares, Min(Open, var4)); } }End

    策略二: ParamsNumeric lots(1);  Numeric PAR_1(2);Numeric PAR_2(12);Numeric PAR_3(4.25);Numeric PAR_4(32);    Numeric PAR_5(2); Numeric PAR_6(1);  Numeric PAR_7(86); Numeric PAR_8(6);  Numeric PAR_9(930);     Numeric PAR_10(1400);   VarsNumericSeries VAR_1;           Numeric VAR_2(0);Numeric VAR_3; Numeric VAR_4; Numeric VAR_5; Numeric VAR_6; NumericSeries VAR_7;        NumericSeries VAR_8;     Numeric VAR_9;Numeric VAR_10;bool boll_1;Numeric tmp;Numeric tmp2;bool boll_2;bool boll_3;bool boll_4;Begin

    VAR_1=AvgTrueRange(PAR_7);
    boll_1=Time>0.0001*PAR_9 And Time <PAR_10 * 0.0001;
    if (BarsSinceEntry == 1){VAR_7 = AvgEntryPrice;VAR_8 = AvgEntryPrice;}Else If(BarsSinceEntry > 1){VAR_7 = Max(VAR_7[1],High[1]);VAR_8 = Min(VAR_8[1],Low[1]);}Else{VAR_7 = VAR_7[1];VAR_8 = VAR_8[1];}

       VAR_6 = MinMove*PriceScale;
    VAR_3=Average(high[1]-low[1],PAR_1);
    VAR_4=Average(open,PAR_2)+VAR_3*PAR_3;VAR_5=Average(open,PAR_2)-VAR_3*PAR_3;

    boll_4=boll_1  and MarketPosition<>-1 && Low<=VAR_5 ;
    boll_3=boll_1  and MarketPosition<>1 && high>=VAR_4 ; If(boll_4)    {     VAR_10 = VAR_5-VAR_2*VAR_6;     If(Open < VAR_5)  VAR_10 = Open-VAR_2*VAR_6;
    sellshort(lots,VAR_10); Return;    }
    If(boll_3)    { VAR_10 = VAR_4+VAR_2*VAR_6;     If(Open > VAR_4)  VAR_10 = Open+VAR_2*VAR_6;  Buy(lots,VAR_10);Return;    }
        If(MarketPosition==1 && BarsSinceEntry >0)   { VAR_9 = EntryPrice * (1-PAR_4/1000);   If (VAR_7 >= EntryPrice * (1 + PAR_5/1000))   { VAR_9 = VAR_7*(1-PAR_6/1000); } } If(Low <= VAR_9)                {  VAR_10 = VAR_9; If(Open < VAR_10) VAR_10 = Open; Sell(Lots,VAR_10); }     Else If(MarketPosition ==-1 && BarsSinceEntry >0)  {        VAR_9 = EntryPrice * (1+PAR_4/1000);   If(VAR_8 <= EntryPrice*(1-PAR_5/1000))   { VAR_9 = VAR_8 * (1+PAR_6/1000); } } If(High >= VAR_9)  { VAR_10 = VAR_9; If(Open > VAR_10)  VAR_10 =Open; BuyToCover(Lots,VAR_10); }
    If(MarketPosition==1) { VAR_9 = VAR_7 - PAR_8*VAR_1[1];           } If(Low <= VAR_9)                {  VAR_10 = VAR_9; If(Open < VAR_10) VAR_10 = Open; Sell(Lots,VAR_10); } Else If(MarketPosition ==-1) { VAR_9 = VAR_8 + PAR_8*VAR_1[1];          } If(High >= VAR_9)  { VAR_10 = VAR_9; If(Open > VAR_10)  VAR_10 =Open; BuyToCover(Lots,VAR_10); }
    End

     

     来源:程序化99

  • 文华技术人员: 您这是tb源码,我们提供软件兼容了TB的语法  
    您复制源码到文华的MQ软件中,稍作修改就可以了,修改如下
    您可以下载免费的模拟试用版体验下:http://www.wenhua.com.cn/

     

     来源: WWW.CXH99.COM

  • 文华客服:   Vars Numeric shares(1); Numeric Params3(2); Numeric Params4(3); Numeric Params2(0.70); Numeric Params1(1.30); Numeric Params5(9.15); Numeric i(0);  Numeric n(0); Numeric var1(0); Numeric var2(0); Numeric var3(0); Numeric var4(0); Numeric var5(0); Numeric var6(0); NumericSeries var7(0); NumericSeries var8(0); NumericSeries var9(0); NumericSeries var10(0); Numeric var11(0); Numeric var12(0); Numeric var13(0); Numeric var14(0); Begin If(CurrentBar == 0 || Date != Date[1]) { var7 = 1; var8 = High; var9 = Low; }Else { var7 = var7 + 1; If(High > var8) var8 = High; If(Low < var9)
    var9 = Low;
    }
    var10 = Close;

    For i = 1 to Params3
    {
    If(i == 1)
    {
    n = var7;
    var11 = var8[n];
    var12 = var9[n];
    var13 = var10[n];
    var14 = var10[n];
    }Else
    {
    n = n + var7[n];
    }
    If(var8[n] > var11) var11 = var8[n];
    If(var9[n] < var12) var12 = var9[n];
    If(var10[n] > var13) var13 = var10[n];
    If(var10[n] < var14) var14 = var10[n];
    }

    var1 = Max(var11 - var14, var13 - var12);

    For i = 1 to Params4
    {
    If(i == 1)
    {
    n = var7;
    var11 = var8[n];
    var12 = var9[n];
    var13 = var10[n];
    var14 = var10[n];
    }Else
    {
    n = n + var7[n];
    }
    If(var8[n] > var11) var11 = var8[n];
    If(var9[n] < var12) var12 = var9[n];
    If(var10[n] > var13) var13 = var10[n];
    If(var10[n] < var14) var14 = var10[n];
    } var2 = Max(var11 - var14, var13 - var12); var3 = OpenD(0) + var1 * Params1; var4 = OpenD(0) - var2 * Params2; var5 = PriceScale * MinMove; If(Time < Params5 / 100) Return; If(MarketPosition  != 1) { If(High >= var3) {
    Buy(shares, Max(Open, var3));
    Return;
    }
    }
    If(MarketPosition != -1)
    {
    If(Low <= var4)
    {
    SellShort(shares, Min(Open, var4));
    }
    } End

     

  • 网友回复:   Params Numeric lots(1);   Numeric PAR_1(2); Numeric PAR_2(12); Numeric PAR_4(32);     Numeric PAR_5(2);  Numeric PAR_6(1);   Numeric PAR_7(86);  Numeric  PAR_8(6);   Numeric PAR_9(930);      Numeric PAR_10(1400);    Vars Numeric PAR_3(4.25); NumericSeries VAR_1;            Numeric VAR_2(0); Numeric VAR_3;  Numeric VAR_4;  Numeric VAR_5;  Numeric VAR_6;  NumericSeries VAR_7;         NumericSeries VAR_8;      Numeric VAR_9; Numeric VAR_10; Numeric boll_1; Numeric tmp; Numeric tmp2; Numeric boll_2; Numeric boll_3; Numeric boll_4; Begin VAR_1=AvgTrueRange(PAR_7); boll_1=Time>0.0001*PAR_9 And Time <PAR_10 * 0.0001; if (BarsSinceEntry == 1) { VAR_7 = AvgEntryPrice; VAR_8 = AvgEntryPrice; } Else If(BarsSinceEntry > 1) { VAR_7 = Max(VAR_7[1],High[1]); VAR_8 = Min(VAR_8[1],Low[1]); } Else { VAR_7 = VAR_7[1]; VAR_8 = VAR_8[1]; }    VAR_6 = MinMove*PriceScale; VAR_3=Average(high[1]-low[1],PAR_1); VAR_4=Average(open,PAR_2)+VAR_3*PAR_3; VAR_5=Average(open,PAR_2)-VAR_3*PAR_3; boll_4=boll_1  and MarketPosition<>-1 && Low<=VAR_5 ; boll_3=boll_1  and MarketPosition<>1 && high>=VAR_4 ;
    If(boll_4)     {      VAR_10 = VAR_5-VAR_2*VAR_6;      If(Open < VAR_5) 
    VAR_10 = Open-VAR_2*VAR_6;

    sellshort(lots,VAR_10);
    Return;     }
    If(boll_3)     {
    VAR_10 = VAR_4+VAR_2*VAR_6;      If(Open > VAR_4) 
    VAR_10 = Open+VAR_2*VAR_6;
      Buy(lots,VAR_10); Return;     }

        If(MarketPosition==1 && BarsSinceEntry >0)  
    {
    VAR_9 = EntryPrice * (1-PAR_4/1000);  

    If (VAR_7 >= EntryPrice * (1 + PAR_5/1000))  
    {
    VAR_9 = VAR_7*(1-PAR_6/1000);
    }
    }
    If(Low <= VAR_9)               

    VAR_10 = VAR_9;
    If(Open < VAR_10) VAR_10 = Open;
    Sell(Lots,VAR_10);
    }     Else If(MarketPosition ==-1 && BarsSinceEntry >0) 
    {       
    VAR_9 = EntryPrice * (1+PAR_4/1000);  

    If(VAR_8 <= EntryPrice*(1-PAR_5/1000))  
    {
    VAR_9 = VAR_8 * (1+PAR_6/1000);
    }
    }
    If(High >= VAR_9) 
    {
    VAR_10 = VAR_9;
    If(Open > VAR_10)  VAR_10 =Open;
    BuyToCover(Lots,VAR_10);
    }
    If(MarketPosition==1)
    {
    VAR_9 = VAR_7 - PAR_8*VAR_1[1];          
    }
    If(Low <= VAR_9)               

    VAR_10 = VAR_9; If(Open < VAR_10) VAR_10 = Open; Sell(Lots,VAR_10); } Else If(MarketPosition ==-1) { VAR_9 = VAR_8 + PAR_8*VAR_1[1];          } If(High >= VAR_9)  { VAR_10 = VAR_9; If(Open > VAR_10)  VAR_10 =Open; BuyToCover(Lots,VAR_10);
    }
    End

 

有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友

可联系技术人员 QQ: 511411198  点击这里给我发消息进行 有偿 编写!不贵!点击查看价格!


【字体: 】【打印文章】【查看评论

相关文章

    没有相关内容