简体   繁体   English

策略测试器中的未知符号但 Metatrader 中的实时数据不是

[英]Unknown Symbols in Strategy Tester but not Live Data in Metatrader

In the strategy tester there are many symbols that I cannot select or get information from in my expert advisor (EA).在策略测试器中,我无法在我的智能交易系统 (EA) 中选择或获取许多交易品种。 In fact, it seems as if there's a bug within MQL4 itself.事实上,MQL4 本身似乎存在一个错误。 I'm attempting to automatically buy and sell in my EA, and it's important that I'm able to get symbol info from other symbols to calculate the correct amount of lots I need.我正在尝试在我的 EA 中自动买卖,重要的是我能够从其他符号中获取符号信息来计算我需要的正确手数。 This doesn't seem to be possible inside the strategy tester.这在策略测试器中似乎是不可能的。

The following EA provides different results when ran in the debugger vs a strategy tester (both using the GBPCAD chart).以下 EA 在调试器和策略测试器中运行时提供不同的结果(均使用 GBPCAD 图表)。

int OnInit(){
  if (!SymbolSelect("USDCAD", true))
    Print("Couldn't select USDCAD");

  if (SymbolInfoInteger("USDCAD", SYMBOL_VISIBLE))
    Print("USDCAD visible");
  else
    Print("USDCAD isn't visible");
    
  double e;
  if (SymbolInfoDouble("USDCAD", SYMBOL_ASK, e))
    Print("It worked");
  else
    Print("It didn't work, ", GetLastError());


  return(INIT_SUCCEEDED);
}

On the debugger in live data, the following is printed:在实时数据中的调试器上,打印以下内容:

2020.08.23 11:25:20.011 Exit Backtester GBPCAD,Daily: USDCAD visible
2020.08.23 11:25:20.011 Exit Backtester GBPCAD,Daily: It worked

On the strategy tester near the beginning of 2017, the following is printed:在接近 2017 年初的策略测试器上,打印了以下内容:

2020.08.23 11:26:01.200 2017.02.09 00:00:00  Exit Backtester GBPCAD,Daily: Couldn't select USDCAD
2020.08.23 11:26:01.200 2017.02.09 00:00:00  Exit Backtester GBPCAD,Daily: USDCAD isn't visible
2020.08.23 11:26:01.200 2017.02.09 00:00:00  Exit Backtester GBPCAD,Daily: It didn't work, 4106

Where error code 4106, according to the documentation , states that the symbol is not selected in Market Watch or found in the list of "available ones".根据文档,错误代码 4106 表明该符号未在市场观察中选择或未在“可用的”列表中找到。

However, running the following code:但是,运行以下代码:

void PrintSymbols(){
  for (int i = 0; i < SymbolsTotal(true); ++i){
    Print(i, " ", SymbolName(i, true));
  }
}

int OnInit(){
  PrintSymbols();
  return(INIT_SUCCEEDED);
}

Prints the same results in both cases, among them being USDCAD:在两种情况下打印相同的结果,其中包括 USDCAD:

2020.08.23 11:38:03.235 Exit Backtester GBPCAD,Daily: 18 USDCAD

So SymbolName proves that USDCAD is available, while SymbolSelect, SymbolInfoInteger, and SymbolInfoDouble prove otherwise.所以 SymbolName 证明 USDCAD 可用,而 SymbolSelect、SymbolInfoInteger 和 SymbolInfoDouble 证明不是。

Why is this the case?为什么会这样?

I don't believe it's possible.我不相信这是可能的。 The strategy tester only loads tick data from the current chart and not another market's data.策略测试器仅从当前图表加载分时数据,而不是其他市场的数据。 Because of this, all other markets don't exist and thus not able to be selected.因此,所有其他市场都不存在,因此无法选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM