为什么OrderSend返回值为-1?

 
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

double Lots=1.1;

bool bool1=true;


void OnStart()
  {
   int ticket;
   if(bool1){
     
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"测试多",123,0,clrNONE);
      Print(rand(),"下多单",Ask,"订单号",ticket);
   }else if(!bool1){
      ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"测试空",345,0,clrNONE);
      Print(rand(),"下空单",Bid,"订单号",ticket);
   };

  }

刚刚接触的新手,尝试写简单的脚本测试,然后发现无法成交, ticket输出为-1

Descubra novos recursos para o MetaTrader 5 com a comunidade e os serviços MQL5
Descubra novos recursos para o MetaTrader 5 com a comunidade e os serviços MQL5
  • 2022.11.08
  • www.mql5.com
MQL5: linguagem de estratégias de negociação inseridas no Terminal do Cliente MetaTrader 5. A linguagem permite escrever seus próprios sistemas automáticos de negócios, indicadores técnicos, scripts e bibliotecas de funções
 

-1表示投出訂單失敗

用GetLastError()檢查錯誤代碼

 
Hung Wen Lin #:

-1表示投出訂單失敗

用GetLastError()檢查錯誤代碼

报4112是什么意思呢
 
sql563526309 #:
报4112是什么意思呢

4112

ERR_TRADE_EXPERT_DISABLED_BY_SERVER

Automated trading by Expert Advisors/Scripts disabled by trade server


可以利用MetaEditor索引找查指令 跟回報代碼的意思

不懂的英文用翻譯軟件翻一下就可以

 
Hung Wen Lin #:

4112

ERR_TRADE_EXPERT_DISABLED_BY_SERVER

Automated trading by Expert Advisors/Scripts disabled by trade server


可以利用MetaEditor索引找查指令 跟回報代碼的意思

不懂的英文用翻譯軟件翻一下就可以

服务器没有开启ea交易,可能是外汇平台不支持ea交易或者程序端没开启自动交易