📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    MT4 均线卖出自动交易系统,最好带30点止损 

    2012-12-08 · 10426 阅读
    MT4   5日均线金叉15日均线买入, 5日均线死叉15日均线卖出自动交易系统,最好带30点止损,100点止赢





    请不要用此类语言,这里都是真诚的朋友,你真心求教,大家会帮你的...

    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 29 个

    admin LV20

    发表于 2012-12-8 14:32:17 | 显示全部楼层

    1. //+------------------------------------------------------------------+
    2. //|                                MA_Crossover_expert_v1.mq4        |
    3. //|                                              Copyright ?2005    |
    4. //|         Copyright ?2005, Jason Robinson (jnrtrading)            |
    5. //|                   http://www.jnrtading.co.uk                     |
    6. //|    Written by MrPip from idea of Jason Robinson                  |                                                    |
    7. //+------------------------------------------------------------------+
    8. #property copyright "Copyright ?2005, Jason Robinson (jnrtrading)"
    9. #property link      "http:/strategybuilderfx.com/"
    10. #include <stdlib.mqh>

    11.           // Change to true to allow print

    12. //+---------------------------------------------------+
    13. //|Account functions                                  |
    14. //+---------------------------------------------------+
    15. extern bool AccountIsMini = false;      // Change to true if trading mini account
    16. //+---------------------------------------------------+
    17. //|Money Management                                   |
    18. //+---------------------------------------------------+
    19. extern bool MoneyManagement = true; // Change to false to shutdown money management controls.
    20.                                     // Lots = 1 will be in effect and only 1 lot will be open regardless of equity.
    21. extern double Riskpercent = 5;      // Change to whatever percent of equity you wish to risk.
    22. extern double DecreaseFactor = 3;   // Used to decrease lot size after a loss is experienced to protect equity.  Recommended not to change.
    23. extern double StopLoss = 35;        // Maximum pips willing to lose per position.
    24. extern double TrailingStop = 0;     // Change to whatever number of pips you wish to trail your position with.
    25. extern double Margincutoff = 800;   // Expert will stop trading if equity level decreases to that level.
    26. extern double Maxtrades = 10;       // Total number of positions on all currency pairs. You can change this number as you wish.
    27. //+---------------------------------------------------+
    28. //|Profit controls                                    |
    29. //+---------------------------------------------------+
    30. extern int TakeProfit = 100;          // Maximum profit level achieved.
    31. extern int Slippage = 10;           // Possible fix for not getting filled or closed   
    32. //+---------------------------------------------------+
    33. //|Indicator Variables                                |
    34. //| Change these to try your own system               |
    35. //| or add more if you like                           |
    36. //+---------------------------------------------------+
    37. extern int FasterMode = 3; //0=sma, 1=ema, 2=smma, 3=lwma, 4 = lsma
    38. extern int FastMAPeriod =   5;
    39. extern int SlowerMode = 1; //0=sma, 1=ema, 2=smma, 3=lwma, 4 = lsma
    40. extern int SlowMAPeriod =   15;

    41. //---- filter parameters


    42. extern double Lots = 1;             // standard lot size.
    43. extern bool Turnon = true;          // Turns expert on, change to false and no trades will take place even if expert is enabled.

    44. //+---------------------------------------------------+
    45. //|General controls                                   |
    46. //+---------------------------------------------------+
    47. string OrderText = "";
    48. double lotMM;
    49. int TradesInThisSymbol;
    50. datetime LastTime;
    51. double Sl;
    52. double Tr;
    53. bool FlatMarket;
    54. int NumBuys, NumSells;             // Number of buy and sell trades in this symbol
    55. bool first_time = true;            // Used to check if first call to SilverTrend


    56. //+------------------------------------------------------------------+
    57. //+------------------------------------------------------------------------+
    58. //| LSMA - Least Squares Moving Average function calculation               |
    59. //| LSMA_In_Color Indicator plots the end of the linear regression line    |
    60. //+------------------------------------------------------------------------+

    61. double LSMA(int Rperiod, int shift)
    62. {
    63.    int i;
    64.    double sum;
    65.    int length;
    66.    double lengthvar;
    67.    double tmp;
    68.    double wt;

    69.    length = Rperiod;

    70.    sum = 0;
    71.    for(i = length; i >= 1  ; i--)
    72.    {
    73.      lengthvar = length + 1;
    74.      lengthvar /= 3;
    75.      tmp = 0;
    76.      tmp = ( i - lengthvar)*Close[length-i+shift];
    77.      sum+=tmp;
    78.     }
    79.     wt = sum*6/(length*(length+1));
    80.    
    81.     return(wt);
    82. }

    83. //+------------------------------------------------------------------+
    84. //| CheckExitCondition                                               |
    85. //| Check if any exit condition is met                               |
    86. //+------------------------------------------------------------------+
    87. bool CheckExitCondition(string TradeType)
    88. {
    89.    bool YesClose;
    90.    double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
    91.    
    92.    YesClose = false;
    93.    if (FasterMode == 4)
    94.    {
    95.       fasterMAnow = LSMA(FastMAPeriod, 2);
    96.       fasterMAprevious = LSMA(FastMAPeriod,3);
    97.       fasterMAafter = LSMA(FastMAPeriod, 1);
    98.    }
    99.    else
    100.    {
    101.       fasterMAnow = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 2);
    102.       fasterMAprevious = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 3);
    103.       fasterMAafter = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 1);
    104.    }
    105.    if (SlowerMode == 4)
    106.    {
    107.       slowerMAnow = LSMA(SlowMAPeriod, 2);
    108.       slowerMAprevious = LSMA(SlowMAPeriod,3);
    109.       slowerMAafter = LSMA(SlowMAPeriod, 1);
    110.    }
    111.    else
    112.    {
    113.       slowerMAnow = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 2);
    114.       slowerMAprevious = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 3);
    115.       slowerMAafter = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 1);
    116.    }
    117.    if (TradeType == "BUY")    // Check for cross down
    118.    {
    119.       if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
    120.       {
    121.        YesClose = true;
    122.       }
    123.    }
    124.    if (TradeType == "SELL")   // Check for cross up
    125.    {
    126.       if ((fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
    127.       {
    128.        YesClose =true;
    129.       }
    130.    }
    131.          
    132. //+------------------------------------------------------------------+
    133. //| Friday Exits                                                     |
    134. //+------------------------------------------------------------------+

    135. //     if(DayOfWeek()==5 && Hour()>=20) YesClose = true;

    136.      return (YesClose);
    137. }

    138. //+------------------------------------------------------------------+
    139. //| CheckEntryCondition                                              |
    140. //| Check if entry condition is met                                  |
    141. //+------------------------------------------------------------------+
    142. bool CheckEntryCondition(string TradeType)
    143. {
    144.    bool YesTrade;
    145.    double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
    146.    
    147.    YesTrade = false;
    148.    if (FasterMode == 4)
    149.    {
    150.       fasterMAnow = LSMA(FastMAPeriod, 2);
    151.       fasterMAprevious = LSMA(FastMAPeriod,3);
    152.       fasterMAafter = LSMA(FastMAPeriod, 1);
    153.    }
    154.    else
    155.    {
    156.       fasterMAnow = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 2);
    157.       fasterMAprevious = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 3);
    158.       fasterMAafter = iMA(NULL, 0, FastMAPeriod, 0, FasterMode, PRICE_CLOSE, 1);
    159.    }
    160.    if (SlowerMode == 4)
    161.    {
    162.       slowerMAnow = LSMA(SlowMAPeriod, 2);
    163.       slowerMAprevious = LSMA(SlowMAPeriod,3);
    164.       slowerMAafter = LSMA(SlowMAPeriod, 1);
    165.    }
    166.    else
    167.    {
    168.       slowerMAnow = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 2);
    169.       slowerMAprevious = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 3);
    170.       slowerMAafter = iMA(NULL, 0, SlowMAPeriod, 0, SlowerMode, PRICE_CLOSE, 1);
    171.    }
    172.    if (TradeType == "BUY")  // Check for cross up
    173.    {
    174.       if ((fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
    175.       {
    176.        YesTrade = true;
    177.       }
    178.    }
    179.    if (TradeType == "SELL")   // Check for cross down
    180.    {
    181.       if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
    182.       {
    183.        YesTrade =true;
    184.       }
    185.    }
    186.    return (YesTrade);
    187. }
    188.   
    189. //+------------------------------------------------------------------+
    190. //| Check if filters allow trades                                    |
    191. //| Return 0 for flat market                                         |
    192. //| return 1 for enough juice for trading                            |
    193. //+------------------------------------------------------------------+


    194. //+------------------------------------------------------------------+
    195. //| expert start function                                            |
    196. //+------------------------------------------------------------------+
    197. int start()
    198.   {
    199. //----

    200.    bool ExitBuy, ExitSell, YesTrade;
    201.    
    202.         int MagicNumber = 3000 + func_Symbol2Val(Symbol())*100 + func_TimeFrame_Const2Val(Period());

    203.    string setup="ma_crossover_expert_v1" + Symbol() + "_" + func_TimeFrame_Val2String(func_TimeFrame_Const2Val(Period()));

    204. // Check for input parameter errors



    205. //+------------------------------------------------------------------+
    206. //| Check for Open Position                                          |
    207. //+------------------------------------------------------------------+

    208.      ExitBuy = CheckExitCondition("BUY");
    209.      ExitSell = CheckExitCondition("SELL");
    210.      HandleOpenPositions(MagicNumber, ExitBuy, ExitSell);
    211.      
    212. // Check if any open positions were not closed

    213.      TradesInThisSymbol = CheckOpenPositions(MagicNumber);
    214.      
    215. //+------------------------------------------------------------------+
    216. //| Check if OK to make new trades                                   |
    217. //+------------------------------------------------------------------+


    218.    if(AccountFreeMargin() < Margincutoff) {
    219.      return(0);}
    220.      
    221. // Only allow 1 trade per Symbol

    222.    if(TradesInThisSymbol > 0) {
    223.      return(0);}
    224.    if(CurTime() < LastTime) {
    225.      return(0);}

    226. // Money Management
    227. // Moved after open positions are closed for more available margin
    228.      
    229.    if(MoneyManagement)
    230.    {
    231.      lotMM = LotsOptimized(MagicNumber);
    232.    }
    233.    else {
    234.      lotMM = Lots; // Change mm to 0 if you want the Lots parameter to be in effect
    235.    }
    236.    
    237.    OrderText = ""; //Must be blank before going into the main section
    238.    
    239.    
    240.         if(CheckEntryCondition("BUY"))
    241.         {
    242.                 OrderText = "BUY";
    243.                 if (StopLoss>0) {
    244.                  Sl = Ask-StopLoss*Point;
    245.                 } else {
    246.                  Sl=0;
    247.                 }
    248.                 if (TakeProfit == 0)
    249.                     Tr = 0;
    250.                 else
    251.                     Tr = Ask+TakeProfit*Point;
    252.         }

    253.    
    254.         if(CheckEntryCondition("SELL") )
    255.         {
    256.                 OrderText = "SELL";
    257.                 if (StopLoss>0) {
    258.                  Sl = Bid+StopLoss*Point;
    259.                 } else {
    260.                  Sl = 0;
    261.                 }
    262.                 if (TakeProfit == 0)
    263.                     Tr = 0;
    264.                 else
    265.                     Tr = Bid-TakeProfit*Point;
    266.         }
    267.    if(OrderText != "" && TradesInThisSymbol == 0 && Turnon)
    268.    {

    269.            LastTime = DoTrades(OrderText,setup,MagicNumber, lotMM,Sl,Tr,CurTime());
    270.       return(0);
    271.    }
    272. //----
    273.    return(0);
    274.   }

    275. //+------------------------------------------------------------------+
    276. //| Functions beyond this point should not need to be modified       |
    277. //| Eventually will be placed in include file                        |
    278. //+------------------------------------------------------------------+



    279. //+-------------------------------------------+
    280. //| DoTrades module cut from start            |
    281. //|  No real changes                          |
    282. //+-------------------------------------------+
    283. datetime DoTrades(string OrdText, string SetupStr,int MagicNum,double lotM, double SSl, double TTr, datetime LstTime)
    284. {
    285.    double Min_OrderPrice;
    286.    int err,tries;
    287.    double dtries;
    288.    int ticket;
    289.    datetime lsttim;

    290.    lsttim = LstTime;
    291.    if(OrdText == "BUY")
    292.    {
    293.        Min_OrderPrice=MinOrderPrice(OP_BUY, MagicNum);
    294.        if (Min_OrderPrice>0 && Min_OrderPrice<=Ask*1.05) {
    295.           Print("Buy too expensive => MinOrderPrice= " + Min_OrderPrice + "  Ask=" + Ask);
    296.        } else {
    297.            tries = 0;
    298.            while (tries < 3)
    299.            {
    300.               ticket = OrderSend(Symbol(),OP_BUY,lotM,Ask,Slippage,SSl,TTr,SetupStr,MagicNum,0,Green);
    301.               lsttim += 12;
    302.               if (ticket <= 0) {
    303.                 tries++;
    304.               } else tries = 3;
    305.            }
    306.            if(ticket<=0) {
    307.               err = GetLastError();
    308.               Alert("Error opening BUY order [" + SetupStr + "]: (" + err + ") " + ErrorDescription(err));
    309.                          }
    310.            return(lsttim);
    311.        }
    312.    }
    313.    else if(OrdText == "SELL")
    314.    {
    315.        Min_OrderPrice=MinOrderPrice(OP_SELL, MagicNum);
    316.        if (Min_OrderPrice>0 && Min_OrderPrice<=Bid) {
    317.           Print("Sell too expensive MinOrderPrice= " + Min_OrderPrice + "  Bid=" + Bid);
    318.        } else {
    319.           tries = 0;
    320.           while (tries < 3)
    321.           {
    322.             ticket = OrderSend(Symbol(),OP_SELL,lotM,Bid,Slippage,SSl,TTr,SetupStr,MagicNum,0,Red);
    323.             lsttim += 12;
    324.             if (ticket <= 0)
    325.             {
    326.               tries++;
    327.              }else tries = 3;
    328.            }
    329.               
    330.             
    331.           if(ticket<=0) {
    332.              err = GetLastError();
    333.              Alert("Error opening Sell order [" + SetupStr + "]: (" + err + ") " + ErrorDescription(err));
    334.                         }
    335.            return(lsttim);
    336.         }
    337.     }
    338.     return(lsttim);
    339. }

    340. //+------------------------------------------------------------------+
    341. //| Check Open Position Controls                                     |
    342. //+------------------------------------------------------------------+
    343.   
    344. int CheckOpenPositions(int MagicNumbers)
    345. {
    346.    int cnt, total, NumPositions;
    347.    int NumBuyTrades, NumSellTrades;   // Number of buy and sell trades in this symbol
    348.    
    349.    NumBuyTrades = 0;
    350.    NumSellTrades = 0;
    351.    total=OrdersTotal();
    352.    for(cnt=0;cnt<total;cnt++)
    353.      {
    354.       if ( OrderSelect (cnt, SELECT_BY_POS) == false )  continue;
    355.       if ( OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumbers)  continue;
    356.       
    357.       if((OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) && (OrderSymbol()==Symbol()))
    358.           {
    359.              NumBuyTrades++;
    360.           }
    361.             
    362.       if((OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) && (OrderSymbol()==Symbol()))
    363.           {
    364.              NumSellTrades++;
    365.           }
    366.             
    367.      }
    368.      NumPositions = NumBuyTrades + NumSellTrades;
    369.      return (NumPositions);
    370.   }


    371. //+------------------------------------------------------------------+
    372. //| Handle Open Positions                                            |
    373. //| Check if any open positions need to be closed or modified        |
    374. //| Three attempts are made to close or modify                       |
    375. //+------------------------------------------------------------------+
    376. int HandleOpenPositions(int MagicNum, bool BuyExit, bool SellExit)
    377. {
    378.    int cnt, total;
    379.    int CloseCnt, err;
    380.    
    381.    total=OrdersTotal();
    382.    for(cnt=0;cnt<total;cnt++)
    383.      {
    384.       if ( OrderSelect (cnt, SELECT_BY_POS) == false )  continue;
    385.       if ( OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNum)  continue;
    386.       
    387.       if((OrderType() == OP_BUY || OrderType() == OP_BUYSTOP) && (OrderSymbol()==Symbol()))
    388.           {
    389.             
    390.             if (BuyExit)
    391.             {
    392.    // try to close 3 Times
    393.       
    394.               CloseCnt = 0;
    395.               while (CloseCnt < 3)
    396.               {
    397.                 if (!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet))
    398.                 {
    399.                  err=GetLastError();
    400.                  Print(CloseCnt," Error closing order : (", err , ") " + ErrorDescription(err));
    401.                  if (err > 0) CloseCnt++;
    402.                 }
    403.                 else
    404.                 {
    405.                  CloseCnt = 3;
    406.                 }
    407.                }
    408.              }
    409.              else
    410.              {
    411.               if(TrailingStop>0)
    412.                {               
    413.                  if(Bid-OrderOpenPrice()>Point*TrailingStop)
    414.                  {
    415.                   if(OrderStopLoss()<Bid-Point*TrailingStop)
    416.                   {
    417.                      CloseCnt=0;
    418.                      while (CloseCnt < 3)
    419.                      {
    420.                      if (!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Aqua))
    421.                      {
    422.                         err=GetLastError();
    423.                         if (err>0) CloseCnt++;
    424.                      }
    425.                      else CloseCnt = 3;
    426.                      }
    427.                   }
    428.                  }
    429.               }
    430.              }
    431.           }

    432.       if((OrderType() == OP_SELL || OrderType() == OP_SELLSTOP) && (OrderSymbol()==Symbol()))
    433.           {
    434.             if (SellExit)
    435.             {
    436.             
    437.    // try to close 3 Times
    438.       
    439.                CloseCnt = 0;
    440.                while (CloseCnt < 3)
    441.                {
    442.                  if (!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Violet))
    443.                  {
    444.                   err=GetLastError();
    445.                   Print(CloseCnt," Error closing order : ",cnt," (", err , ") " + ErrorDescription(err));
    446.                   if (err > 0) CloseCnt++;
    447.                  }
    448.                  else CloseCnt = 3;
    449.                }
    450.              }
    451.              else
    452.              {
    453.   
    454.    // try to modify 3 Times
    455.       
    456.                  if(TrailingStop>0)  
    457.                  {               
    458.                   if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
    459.                   {
    460.                    if(OrderStopLoss()==0.0 || OrderStopLoss()>(Ask+Point*TrailingStop))
    461.                    {
    462.                      CloseCnt = 0;
    463.                      while (CloseCnt < 3)
    464.                      {
    465.                        if (!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Aqua))
    466.                        {
    467.                          err=GetLastError();
    468.                          if (err > 0) CloseCnt++;
    469.                        }
    470.                        else CloseCnt = 3;
    471.                      }
    472.                    }
    473.                   }
    474.                 }
    475.              }
    476.        }
    477.   }
    478. }

    479.      
    480. //+------------------------------------------------------------------+
    481. //| Calculate optimal lot size                                       |
    482. //+------------------------------------------------------------------+

    483. double LotsOptimized(int Mnr)
    484.   {
    485.    double lot=Lots;
    486.    int    orders=HistoryTotal();     // history orders total
    487.    int    losses=0;                  // number of losses orders without a break
    488.    int    tolosses=0;
    489. //---- select lot size
    490.    lot=NormalizeDouble(MathFloor(AccountFreeMargin()*Riskpercent/10000)/10,1);
    491.    
    492. //---- calculate number of losses orders without a break
    493.    if(DecreaseFactor>0)
    494.      {
    495.       for(int i=orders-1;i>=0;i--)
    496.         {
    497.          if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
    498.          if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL || OrderMagicNumber()!=Mnr) continue;
    499.          //----
    500.          if(OrderProfit()>0) break;
    501.          if(OrderProfit()<0) losses++;
    502.         }
    503.       for(i=orders-1;i>=0;i--)
    504.         {
    505.          if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
    506.          if(TimeDay(OrderCloseTime()) != TimeDay(CurTime())) continue;
    507.          //----
    508.          if(OrderProfit()<0) tolosses++;
    509.         }
    510.       if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
    511.      }
    512.   
    513.   // lot at this point is number of standard lots
    514.   
    515. //  if (Debug) Print ("Lots in LotsOptimized : ",lot);
    516.   
    517.   // Check if mini or standard Account
    518.   
    519.   if(AccountIsMini)
    520.   {
    521.     lot = MathFloor(lot);
    522.     lot = lot / 10;
    523.    
    524. // Use at least 1 mini lot

    525.    if(lot<0.1) lot=0.1;

    526.   }else
    527.   {
    528.     if (lot < 1.0) lot = 1.0;
    529.     if (lot > 100) lot = 100;
    530.   }

    531.    return(lot);
    532.   }

    533. //+------------------------------------------------------------------+
    534. //| Time frame interval appropriation  function                      |
    535. //+------------------------------------------------------------------+

    536. int func_TimeFrame_Const2Val(int Constant ) {
    537.    switch(Constant) {
    538.       case 1:  // M1
    539.          return(1);
    540.       case 5:  // M5
    541.          return(2);
    542.       case 15:
    543.          return(3);
    544.       case 30:
    545.          return(4);
    546.       case 60:
    547.          return(5);
    548.       case 240:
    549.          return(6);
    550.       case 1440:
    551.          return(7);
    552.       case 10080:
    553.          return(8);
    554.       case 43200:
    555.          return(9);
    556.    }
    557. }

    558. //+------------------------------------------------------------------+
    559. //| Time frame string appropriation  function                               |
    560. //+------------------------------------------------------------------+

    561. string func_TimeFrame_Val2String(int Value ) {
    562.    switch(Value) {
    563.       case 1:  // M1
    564.          return("PERIOD_M1");
    565.       case 2:  // M1
    566.          return("PERIOD_M5");
    567.       case 3:
    568.          return("PERIOD_M15");
    569.       case 4:
    570.          return("PERIOD_M30");
    571.       case 5:
    572.          return("PERIOD_H1");
    573.       case 6:
    574.          return("PERIOD_H4");
    575.       case 7:
    576.          return("PERIOD_D1");
    577.       case 8:
    578.          return("PERIOD_W1");
    579.       case 9:
    580.          return("PERIOD_MN1");
    581.            default:
    582.                    return("undefined " + Value);
    583.    }
    584. }

    585. int func_Symbol2Val(string symbol) {
    586.         if(symbol=="AUDCAD") {
    587.                 return(1);
    588.         } else if(symbol=="AUDJPY") {
    589.                 return(2);
    590.         } else if(symbol=="AUDNZD") {
    591.                 return(3);
    592.         } else if(symbol=="AUDUSD") {
    593.                 return(4);
    594.         } else if(symbol=="CHFJPY") {
    595.                 return(5);
    596.         } else if(symbol=="EURAUD") {
    597.                 return(6);
    598.         } else if(symbol=="EURCAD") {
    599.                 return(7);
    600.         } else if(symbol=="EURCHF") {
    601.                 return(8);
    602.         } else if(symbol=="EURGBP") {
    603.                 return(9);
    604.         } else if(symbol=="EURJPY") {
    605.                 return(10);
    606.         } else if(symbol=="EURUSD") {
    607.                 return(11);
    608.         } else if(symbol=="GBPCHF") {
    609.                 return(12);
    610.         } else if(symbol=="GBPJPY") {
    611.                 return(13);
    612.         } else if(symbol=="GBPUSD") {
    613.                 return(14);
    614.         } else if(symbol=="NZDUSD") {
    615.                 return(15);
    616.         } else if(symbol=="USDCAD") {
    617.                 return(16);
    618.         } else if(symbol=="USDCHF") {
    619.                 return(17);
    620.         } else if(symbol=="USDJPY") {
    621.                 return(18);
    622.         } else {
    623.                 Comment("unexpected Symbol");
    624.                 return(0);
    625.         }
    626. }

    627. //+------------------------------------------------------------------+
    628. //| Average price efficiency  function                               |
    629. //+------------------------------------------------------------------+

    630. double MinOrderPrice(int OType, int OMagicNumber) {
    631. double MinPrice;

    632.    if (OrderType()==OP_BUY) {
    633.       MinPrice=1000000;
    634.    } else {
    635.       MinPrice=0;
    636.    }

    637.    for(int cnt=0;cnt<OrdersTotal();cnt++)
    638.    {
    639.       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    640.       
    641.       if(OrderType()==OType && OrderSymbol()==Symbol() && OrderMagicNumber()==OMagicNumber) {
    642.          if (OrderType()==OP_BUY) {
    643.             if (OrderOpenPrice()<MinPrice) {
    644.                MinPrice=OrderOpenPrice();
    645.             }
    646.          } else {
    647.             if (OrderOpenPrice()>MinPrice) {
    648.                MinPrice=OrderOpenPrice();
    649.             }
    650.          }
    651.       }
    652.    }
    653.    if (MinPrice==1000000) MinPrice=0;
    654.    return(MinPrice);
    655.    
    656. }


    657. //+------------------------------------------------------------------+
    复制代码

    ti操盘 LV3

    发表于 2012-12-8 14:32:45 | 显示全部楼层

    系统交易不好赢利啊

    qq12615987 LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    不是吧  

    why9250 LV5

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    哈哈,看的人少,回一下  

    ea专业户 LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    楼主good  

    q543777345 LV5

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    我有一个EA 好坏你自己定  免费的  需要的话 可以发给你玩玩  

    亿博 LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    貌似我真的很笨????哎  

    万元富 LV4

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    老大,我好崇拜你哟  

    杂乱手机 LV3

    发表于 2012-12-8 15:01:10 | 显示全部楼层

    真是有你的!  
    1234下一页
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服