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

[求助]转换问题 [文华财经]

  • 咨询内容:  楼主,我这里有一个MT4的指标想要转换到文华上来,等下我发源码上来,麻烦帮忙修改下

     

     来源:程序化99

  • 文华技术人员:  


    #property copyright "GJ Pavkovich"
    #property link      "www.sniperforex.com"

    #property indicator_chart_window
    #property indicator_buffers 6
    #property indicator_color1 Blue
    #property indicator_color2 Red
    #property indicator_color3 Blue
    #property indicator_color4 Red
    #property indicator_color5 Blue
    #property indicator_color6 Red

    extern int SniperPeriod = 30;
    extern int SniperType = 3;
    extern int arrow_shift = 30;
    extern int Alerts = 1;
    double g_ibuf_92[];
    double g_ibuf_96[];
    double g_ibuf_100[];
    double g_ibuf_104[];
    double g_ibuf_108[];
    double g_ibuf_112[];
    bool gi_116 = TRUE;
    int gi_unused_120;
    bool gi_124;
    bool gi_128;
    string gs_shma_132 = "SHMA";
    string gs_140 = "Sniper Forex, copyright GJ Pavkovich 88754897533568";

    int init() {
       ObjectsDeleteAll();
       SetIndexBuffer(0, g_ibuf_92);
       SetIndexBuffer(1, g_ibuf_96);
       SetIndexBuffer(2, g_ibuf_100);
       SetIndexBuffer(3, g_ibuf_104);
       SetIndexBuffer(4, g_ibuf_108);
       SetIndexBuffer(5, g_ibuf_112);
       SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2);
       gi_116 = TRUE;
       return (0);
    }

    int start() {
       string ls_unused_12;
       string ls_0 = "2020.09.09";
       int l_str2time_8 = StrToTime(ls_0);
       if (TimeCurrent() >= l_str2time_8) {
          Alert("Trial version expired! Contact www.sniperforex.com.");
          return (0);
       }
       if (gi_116) {
          gi_116 = FALSE;
          for (int li_20 = Bars; li_20 >= 0; li_20--) {
             g_ibuf_92[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 2, gs_140, 1, li_20);
             g_ibuf_96[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 2, gs_140, 2, li_20);
             g_ibuf_100[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 3, gs_140, 1, li_20);
             g_ibuf_104[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 3, gs_140, 2, li_20);
             g_ibuf_108[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 4, gs_140, 1, li_20);
             g_ibuf_112[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 4, gs_140, 2, li_20);
             DoCheck(li_20);
          }
       } else {
          for (li_20 = 3; li_20 >= 0; li_20--) {
             g_ibuf_92[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 2, gs_140, 1, li_20);
             g_ibuf_96[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 2, gs_140, 2, li_20);
             g_ibuf_100[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 3, gs_140, 1, li_20);
             g_ibuf_104[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 3, gs_140, 2, li_20);
             g_ibuf_108[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 4, gs_140, 1, li_20);
             g_ibuf_112[li_20] = iCustom(Symbol(), 0, gs_shma_132, SniperPeriod, SniperType, 4, gs_140, 2, li_20);
          }
          DoCheck(0);
          gi_unused_120 = Bars;
       }
       return (0);
    }

    void DoCheck(int ai_0) {
       string l_name_4;
       if (g_ibuf_108[ai_0] != EMPTY_VALUE && g_ibuf_108[ai_0 + 1] != EMPTY_VALUE && !gi_124) {
          gi_124 = TRUE;
          if (ai_0 == 0) {
             l_name_4 = "Imminent long trade alert on " + Symbol() + ", " + GetTimeFrame() + ", " + TimeToStr(TimeLocal()) + ", Bid=" + DoubleToStr(Bid, Digits);      }      break;      break;
          break;
       case PERIOD_M30:
          ls_ret_0 = "M30";
          break;
       case PERIOD_H1:
          ls_ret_0 = "H1";
          break;
       case PERIOD_H4:
          ls_ret_0 = "H4";
          break;
       case PERIOD_D1:
          ls_ret_0 = "D1";
          break;
       case PERIOD_W1:
          ls_ret_0 = "W1";
          break;
       case PERIOD_MN1:
          ls_ret_0 = "MN";
       }
       return (ls_ret_0);
    }

     

     来源: WWW.CXH99.COM

  • 文华客服:  


    #property copyright "Freely Available"
    #property link      "keeper-of-the-thatch@thepub.co.za"

    #property indicator_chart_window
    #property indicator_buffers 3
    #property indicator_color1 White
    #property indicator_color2 Blue
    #property indicator_color3 Red

    extern int period = 34;
    extern int method = 3;
    extern int price = 0;
    extern string C = "";
    double g_ibuf_96[];
    double g_ibuf_100[];
    double g_ibuf_104[];
    int gi_108 = 0;

    int init() {
       gi_108 = TimeCurrent() - TimeCurrent() % (60 * Period()) - 60 * Period();
       IndicatorBuffers(3);
       SetIndexBuffer(1, g_ibuf_96);
       SetIndexBuffer(2, g_ibuf_100);
       SetIndexBuffer(0, g_ibuf_104);
       ArraySetAsSeries(g_ibuf_104, TRUE);
       SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
       SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
       IndicatorShortName("Hull Moving Average alert(" + period + ")");
       return (0);
    }

    int deinit() {
       return (0);
    }

    double WMA(int ai_0, int a_period_4) {
       return (iMA(NULL, 0, a_period_4, 0, method, price, ai_0));
    }

    int start() {
       int li_0;
       int li_4;
       int li_8;
       int l_period_12;
       int li_16;
       double lda_20[];
       double lda_24[];
       if (C == "Sniper Forex, copyright GJ Pavkovich 88754897533568") {
          li_0 = IndicatorCounted();
          if (li_0 < 0) return (-1);
          if (li_0 > 0) li_0--;
          li_4 = Bars - li_0;
          li_8 = 0;
          l_period_12 = MathSqrt(period);
          li_16 = Bars - li_0 + period + 1;
          if (li_16 > Bars) li_16 = Bars;
          ArrayResize(lda_20, li_16);
          ArraySetAsSeries(lda_20, TRUE);
          ArrayResize(lda_24, li_16);
          ArraySetAsSeries(lda_24, TRUE);
          for (li_8 = 0; li_8 < li_16; li_8++) lda_20[li_8] = 2.0 * WMA(li_8, period / 2) - WMA(li_8, period);
          for (li_8 = 0; li_8 < li_16 - period; li_8++) g_ibuf_104[li_8] = iMAOnArray(lda_20, 0, l_period_12, 0, method, li_8);
          for (li_8 = li_16 - period; li_8 >= 0; li_8--) {
             lda_24[li_8] = lda_24[li_8 + 1];
             if (g_ibuf_104[li_8] > g_ibuf_104[li_8 + 1]) lda_24[li_8] = 1;
             if (g_ibuf_104[li_8] < g_ibuf_104[li_8 + 1]) lda_24[li_8] = -1;
             if (lda_24[li_8] > 0.0) {
                g_ibuf_96[li_8] = g_ibuf_104[li_8];
                if (lda_24[li_8 + 1] < 0.0) g_ibuf_96[li_8 + 1] = g_ibuf_104[li_8 + 1];
                g_ibuf_100[li_8] = EMPTY_VALUE;
             } else {
                if (lda_24[li_8] < 0.0) {
                   g_ibuf_100[li_8] = g_ibuf_104[li_8];
                   if (lda_24[li_8 + 1] > 0.0) g_ibuf_100[li_8 + 1] = g_ibuf_104[li_8 + 1];
                   g_ibuf_96[li_8] = EMPTY_VALUE;
                }
             }
          }
          return (0);
       }
    }

     

  • 网友回复:  

    //+------------------------------------------------------------------+
    //|                                  Sniper Forex Expert Advisor.mq4 |
    //|                              Copyright ?2008, TradingSytemForex |
    //|                                http://www.tradingsystemforex.com |
    //+------------------------------------------------------------------+

    #property copyright "Copyright ?2008, TradingSytemForex"
    #property link "http://www.tradingsystemforex.com"

    #define OrSt "Sniper Forex Expert Advisor"

    extern string SNI="---------------- Sniper";
    extern int SniperPeriod=30;
    extern int SniperType=3;
    extern string STB="---------------- Sniper Trend B";
    extern double Sniper=0.01;
    extern int SniperP=7;
    extern string LM="---------------- Lot Management";
    extern double Lots=0.1;
    extern bool MM=false; //money management
    extern double Risk=10; //risk in percentage
    extern string TSTB="---------------- TP SL TS BE";
    bool RealSL_Enabled=false;
    int RealSL=5; //stop loss under 15 p頿s
    bool RealTP_Enabled=false;
    int RealTP=10; //take profit under 10 p頿s
    extern int SL=0; //stop loss
    extern int TP=0; //take profit
    extern int TS=0; //trailing stop
    extern int TS_Step=1; //trailing stop step
    extern int BE=0; //breakeven
    extern string EXT="---------------- Extras";
    extern bool Reverse=false;
    extern bool Add_Positions=false; //positions cumulated
    extern int MaxOrders=100; //maximum number of orders
    extern int Magic=0;

    int Slip=3;static int TL=0;double MML=0;

    // expert start function
    int start(){int j=0,limit=1;double BV=0,SV=0;BV=0;SV=0;double SNIB1,SNIB2,SNIA1,SNIA2,SNI1,SNI2,SNI3,SNI4,SNI5,SNI6,SNI1b,SNI2b,SNI3b,SNI4b,SNI5b,SNI6b;
    if(CntO(OP_BUY,Magic)>0)TL=1;if(CntO(OP_SELL,Magic)>0)TL=-1;for(int i=1;i<=limit;i++){

    SNIA1=iCustom(Symbol(),0,"Sniper Trend A",0,i);
    SNIA2=iCustom(Symbol(),0,"Sniper Trend A",1,i);
    SNIB1=iCustom(Symbol(),0,"Sniper Trend B",Sniper,SniperP,0,i);
    SNIB2=iCustom(Symbol(),0,"Sniper Trend B",Sniper,SniperP,1,i);
    SNI1=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,0,i);
    SNI1b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,0,0);
    SNI2=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,1,i);
    SNI2b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,1,0);
    SNI3=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,2,i);
    SNI3b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,2,0);
    SNI4=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,3,i);
    SNI4b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,3,0);
    SNI5=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,4,i);
    SNI5b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,4,0);
    SNI6=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,5,i);
    SNI6b=iCustom(Symbol(),0,"Sniper",SniperPeriod,SniperType,5,0);

    if(SNI1!=EMPTY_VALUE&&SNI1b!=EMPTY_VALUE&&SNI3!=EMPTY_VALUE&&SNI3b!=EMPTY_VALUE&&SNI5!=EMPTY_VALUE&&SNI5b!=EMPTY_VALUE&&SNIA1>0&&SNIB2>0){if(Reverse)SV=1;else BV=1;break;}
    if(SNI2!=EMPTY_VALUE&&SNI2b!=EMPTY_VALUE&&SNI4!=EMPTY_VALUE&&SNI4b!=EMPTY_VALUE&&SNI6!=EMPTY_VALUE&&SNI6b!=EMPTY_VALUE&&SNIA2>0&&SNIB1>0){if(Reverse)BV=1;else SV=1;break;}}

    // expert money management
    if(MM){if(Risk<0.1||Risk>100){Comment("Invalid Risk Value.");return(0);}
    else{MML=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);}}
    if(MM==false){MML=Lots;}

    // expert init positions
    int cnt=0,OP=0,OS=0,OB=0,CS=0,CB=0;OP=0;for(cnt=0;cnt<OrdersTotal();cnt++){OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if((OrderType()==OP_SELL||OrderType()==OP_BUY)&&OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0))OP=OP+1;}
    if(OP>=1){OS=0; OB=0;}OB=0;OS=0;CB=0;CS=0;

    // expert conditions to open position
    if(SV>0){OS=1;OB=0;}if(BV>0){OB=1;OS=0;}

    // expert conditions to close position
    if((SV>0)||(RealSL_Enabled&&(OrderOpenPrice()-Bid)/Point>=RealSL)||(RealTP_Enabled&&(Ask-OrderOpenPrice())/Point>=RealTP)){CB=1;}
    if((BV>0)||(RealSL_Enabled&&(Ask-OrderOpenPrice())/Point>=RealSL)||(RealTP_Enabled&&(OrderOpenPrice()-Bid)/Point>=RealTP)){CS=1;}
    for(cnt=0;cnt<OrdersTotal();cnt++){OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if(OrderType()==OP_BUY&&OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0)){if(CB==1){OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red);return(0);}}
    if(OrderType()==OP_SELL&&OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0)){
    if(CS==1){OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red);return(0);}}}double SLI=0,TPI=0;int TK=0;

    // expert open position value
    if((AddP()&&Add_Positions&&OP<=MaxOrders)||(OP==0&&!Add_Positions)){
    if(OS==1){if(TP==0)TPI=0;else TPI=Bid-TP*Point;if(SL==0)SLI=0;else SLI=Bid+SL*Point;TK=OrderSend(Symbol(),OP_SELL,MML,Bid,Slip,SLI,TPI,OrSt,Magic,0,Red);OS=0;return(0);} 
    if(OB==1){if(TP==0)TPI=0;else TPI=Ask+TP*Point;if(SL==0)SLI=0;else SLI=Ask-SL*Point;TK=OrderSend(Symbol(),OP_BUY,MML,Ask,Slip,SLI,TPI,OrSt,Magic,0,Lime);OB=0; return(0);}}
    for(j=0;j<OrdersTotal();j++){if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0)){TrP();}}}return(0);}

    // expert number of orders
    int CntO(int Type,int Magic){int _CntO;_CntO=0;
    for(int j=0;j<OrdersTotal();j++){OrderSelect(j,SELECT_BY_POS,MODE_TRADES);if(OrderSymbol()==Symbol()){if((OrderType()==Type&&(OrderMagicNumber()==Magic)||Magic==0))_CntO++;}}return(_CntO);}

    //expert breakeven
    void TrP(){double pb,pa,pp;pp=MarketInfo(OrderSymbol(),MODE_POINT);if(OrderType()==OP_BUY){pb=MarketInfo(OrderSymbol(),MODE_BID);
    if(BE>0){if((pb-OrderOpenPrice())>BE*pp){if((OrderStopLoss()-OrderOpenPrice())<0){ModSL(OrderOpenPrice()+0*pp);}}}

    // expert trailing stop
    if(TS>0){if((pb-OrderOpenPrice())>TS*pp){if(OrderStopLoss()<pb-(TS+TS_Step-1)*pp){ModSL(pb-TS*pp);return;}}}}
    if(OrderType()==OP_SELL){pa=MarketInfo(OrderSymbol(),MODE_ASK);if(BE>0){if((OrderOpenPrice()-pa)>BE*pp){if((OrderOpenPrice()-OrderStopLoss())<0){ModSL(OrderOpenPrice()-0*pp);}}}
    if(TS>0){if(OrderOpenPrice()-pa>TS*pp){if(OrderStopLoss()>pa+(TS+TS_Step-1)*pp||OrderStopLoss()==0){ModSL(pa+TS*pp);return;}}}}}

    //expert stoploss
    void ModSL(double ldSL){bool fm;fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldSL,OrderTakeProfit(),0,CLR_NONE);}

    //expert add positions function
    bool AddP(){int _num=0; int _ot=0;
    for (int j=0;j<OrdersTotal();j++){if(OrderSelect(j,SELECT_BY_POS)==true && OrderSymbol()==Symbol()&&OrderType()<3&&((OrderMagicNumber()==Magic)||Magic==0)){ 
    _num++;if(OrderOpenTime()>_ot) _ot=OrderOpenTime();}}if(_num==0) return(true);if(_num>0 && ((Time[0]-_ot))>0) return(true);else return(false);}

     

  • 网友回复:  


    #property copyright "Copyright ?2008, GJ Pavkovich.com "
    #property link      "http://www.sniperforex.com/"

    #property indicator_chart_window
    #property indicator_buffers 2
    #property indicator_color1 Blue
    #property indicator_color2 Red

    double gd_76 = 15.0;
    double g_period_84 = 14.0;
    double gd_92 = 3.0;
    double gd_100 = 0.0;
    double g_ibuf_108[];
    double g_ibuf_112[];
    double g_ibuf_116[];
    double g_ibuf_120[];
    double g_ibuf_124[];

    int init() {
       SetIndexStyle(0, DRAW_ARROW);
       SetIndexArrow(0, 159);
       SetIndexStyle(1, DRAW_ARROW);
       SetIndexArrow(1, 159);
       IndicatorBuffers(5);
       SetIndexBuffer(0, g_ibuf_108);
       SetIndexBuffer(1, g_ibuf_112);
       SetIndexBuffer(2, g_ibuf_116);
       SetIndexBuffer(3, g_ibuf_120);
       SetIndexBuffer(4, g_ibuf_124);
       string ls_0 = "Sniper Stop(" + gd_76 + ")";
       IndicatorShortName(ls_0);
       SetIndexLabel(0, "Up");
       SetIndexLabel(1, "Dn");
       SetIndexDrawBegin(0, gd_76);
       SetIndexDrawBegin(1, gd_76);
       return (0);
    }

    int start() {
       int li_16;
       string ls_0 = "2020.09.09";
       int l_str2time_8 = StrToTime(ls_0);
       if (TimeCurrent() >= l_str2time_8) {
          Alert("Trial version expired! Contact www.sniperforex.com.");
          return (0);
       }
       int l_ind_counted_20 = IndicatorCounted();
       if (l_ind_counted_20 > 0) li_16 = Bars - l_ind_counted_20;
       if (l_ind_counted_20 < 0) return (0);
       if (l_ind_counted_20 == 0) li_16 = Bars - gd_76 - 1.0;
       for (int li_12 = li_16; li_12 >= 0; li_12--) {
          g_ibuf_116[li_12] = High[iHighest(NULL, 0, MODE_HIGH, gd_76, li_12 + gd_100)] - gd_92 * iATR(NULL, 0, g_period_84, li_12 + gd_100);
          g_ibuf_120[li_12] = Low[iLowest(NULL, 0, MODE_LOW, gd_76, li_12 + gd_100)] + gd_92 * iATR(NULL, 0, g_period_84, li_12 + gd_100);
          g_ibuf_124[li_12] = g_ibuf_124[li_12 + 1];
          if (Close[li_12] > g_ibuf_120[li_12 + 1]) g_ibuf_124[li_12] = 1;
          if (Close[li_12] < g_ibuf_116[li_12 + 1]) g_ibuf_124[li_12] = -1;
          if (g_ibuf_124[li_12] > 0.0) {
             if (g_ibuf_116[li_12] < g_ibuf_116[li_12 + 1]) g_ibuf_116[li_12] = g_ibuf_116[li_12 + 1];
             g_ibuf_108[li_12] = g_ibuf_116[li_12];
             g_ibuf_112[li_12] = EMPTY_VALUE;
          }
          if (g_ibuf_124[li_12] < 0.0) {
             if (g_ibuf_120[li_12] > g_ibuf_120[li_12 + 1]) g_ibuf_120[li_12] = g_ibuf_120[li_12 + 1];
             g_ibuf_108[li_12] = EMPTY_VALUE;
             g_ibuf_112[li_12] = g_ibuf_120[li_12];
          }
       }
       return (0);
    }

 

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

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


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

相关文章

    没有相关内容