請問,我測程式時為何程式都沒有交易. when i test program, no any trade made by program, why ?

 

參數都有設定,可是程式跑完結果都沒有交易資料。

我測這個文章中討論的程式 https://www.mql5.com/en/articles/647

 I've been verify all necessary parameter and procedure, but not any trade which program made after test , why ?

anybody can help me ?

I test the program downloaded from here https://www.mql5.com/en/articles/647 

 

我测试了一下,没有问题。将测试时间段放长一点。

 

 

 
luenbo:

我测试了一下,没有问题。将测试时间段放长一点。

 

謝謝回應, 我把時段放長到一年,total trade 也是0。

我用linux + wine,應該不是平台的問題。我測預設的ExpertMAPSarSizeOptimize都有資料 

 

會不會是我的測試步驟還有設定有問題,我下載的EA大部份都測不出數字。

只有MT5系統內建的有結果 

 

不知道是那裡出問題

 

 

 

那你看下日志,有什么报错没有?

 

 
luenbo:

那你看下日志,有什么报错没有?

 沒有Error,很正常,就是沒有交易。但我測ExpertMAPSARSizeOptimized就是可以。

是不是Input的參數都要勾起來? 

 
kego.tong:

是不是程式要改,或者特別要設定什麼?

我下載連結中的zip檔,解開之後有個ElderThreeScreens資料夾,將它整個放在MQL5\Expert 中. 然後strategy tester就能選到。

 
不管有沒有開visualization,都沒有trade event 出來
 

     一个品种symbol有4种执行模式:

ENUM_SYMBOL_TRADE_EXECUTION

Identifier

Description

SYMBOL_TRADE_EXECUTION_REQUEST

Execution by request

SYMBOL_TRADE_EXECUTION_INSTANT

Instant execution

SYMBOL_TRADE_EXECUTION_MARKET

Market execution

SYMBOL_TRADE_EXECUTION_EXCHANGE

Exchange execution

 

    原库文件 TradeFunctions.mqh 中的 OpenPosition()函数没有包括第四种情况(Exchange), 而楼主你用的Alpari MT5 恰好采取的是 Exchange模式

    Exchange 与 Market 目前是一回事。(见官方管理员的解释https://www.mql5.com/en/forum/7409)

    我把Exchage包括进去了,修改了OpenPosition()函数如下。

    或者你直接用已经修改好的库文件替换,见附件。  

  
//+------------------------------------------------------------------+
//| Opening a position                                               |
//+------------------------------------------------------------------+
void OpenPosition(double lot,
                  ENUM_ORDER_TYPE order_type,
                  double price,
                  double sl,
                  double tp,
                  string comment)
  {
//--- Set the magic number in the trading structure
   trade.SetExpertMagicNumber(MagicNumber);
//--- Set the slippage in points
   trade.SetDeviationInPoints(CorrectValueBySymbolDigits(Deviation));
   
   // Comment(" sym exe mode = ",EnumToString(symb.execution_mode)); //测试是SYMBOL_TRADE_EXECUTION_EXCHANGE

//--- The Instant Execution mode
//    A position can be opened with the Stop Loss and Take Profit levels set
   if(symb.execution_mode==SYMBOL_TRADE_EXECUTION_INSTANT)
     {
      //--- If the position failed to open, print the relevant message
      if(!trade.PositionOpen(_Symbol,order_type,lot,price,sl,tp,comment))
         Print("Error opening the position: ",GetLastError()," - ",ErrorDescription(GetLastError()));
     }
//--- The Market Execution mode 
//    First open a position and only then set the Stop Loss and Take Profit levels
//    *** Starting with build 803, Stop Loss and Take Profit can be set upon position opening ***
   //if(symb.execution_mode==SYMBOL_TRADE_EXECUTION_MARKET) //缺少 symb.execution_mode ==SYMBOL_TRADE_EXECUTION_EXCHANGE
   if(symb.execution_mode==SYMBOL_TRADE_EXECUTION_MARKET||symb.execution_mode ==SYMBOL_TRADE_EXECUTION_EXCHANGE)
     {
      //--- If there is no position, first open a position and then set Stop Loss and Take Profit
      if(!pos.exists)
        {
         //--- If the position failed to open, print the relevant message
         if(!trade.PositionOpen(_Symbol,order_type,lot,price,0,0,comment))
            Print("Error opening the position: ",GetLastError()," - ",ErrorDescription(GetLastError()));
         else
           {
            //--- Get the flag of presence/absence of the position
            pos.exists=PositionSelect(_Symbol);
            //--- If the position exists
            if(pos.exists)
              {
               //--- Set Stop Loss and Take Profit
               if(!trade.PositionModify(_Symbol,sl,tp))
                  Print("Error modifying the position: ",GetLastError()," - ",ErrorDescription(GetLastError()));
              }
           }

        }
      //--- If the position exists, increase its volume and leave the Stop Loss and Take Profit levels unchanged
      else
        {
         //--- If the position failed to open, print the relevant message
         if(!trade.PositionOpen(_Symbol,order_type,lot,price,sl,tp,comment))
            Print("Error opening the position: ",GetLastError()," - ",ErrorDescription(GetLastError()));
        }
     }
  }
附加的文件:
 
kego.tong:
不管有沒有開visualization,都沒有trade event 出來
#include <Trade/Trade.mqh>
#include <Trade/SymbolInfo.mqh>
#include <Trade/PositionInfo.mqh>
我觉得用官方的库文件就足够了,安全可靠!用不着自己再去写什么库,搞不好丢三落四。
原因: