"Trade is disabled" error in MT4

 

Hello All!

I've been watching a lot of tutorials on how to make scripts and EA's and I'm having an issue trying to get my EA to place a buy order on the market as a test. I get the following error. I do have it in the EA folder and I have allowed live trading when the inputs screen comes up.

2019.03.24 21:56:52.092               '11123847': order buy 0.01 EURUSD opening at market sl: 1.12944 tp: 1.12964 failed [Trade is disabled]


The following is my code. 

//+------------------------------------------------------------------+
//|                                             HelloWorldExpert.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
extern int TakeProfit = 10;
extern int StopLoss = 10;
int P;
int OnInit()
{
  //---
if(Digits == 5 || Digits == 3 || Digits == 1)P = 10;else P = 1; // To account for 5 digit brokers

  //---
  return (INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  //---
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
  //---
  double hma_20 = iCustom(NULL, 0, "HMA", 20, 0, MODE_LWMA, 5, 0, 0);
  double hma_13 = iCustom(NULL, 0, "HMA", 13, 0, MODE_LWMA, 5, 0, 0);

  double TakeProfitLevel;
  double StopLossLevel;

  TakeProfitLevel = Bid + 10 * Point; // 0.0001
  StopLossLevel = Bid - 10 * Point;   // 0.0001

  Alert("TakeProfitLevel = ", TakeProfitLevel);
  Alert("StopLossLevel = ", StopLossLevel);
  Alert("HMA is = ", hma_13);
  Alert("HMA is = ", hma_20);

  int ticket;
  ticket = OrderSend("EURUSD", OP_BUY, 0.01, Ask, 10, StopLossLevel, TakeProfitLevel, "MyFirstOrder");

  if (ticket < 0)
  {
    int error = GetLastError();
    Alert(error);
  }
  else
  {
    Alert("Your ticket number is " + string(ticket));
  }
}
//+------------------------------------------------------------------+

Thoughts?

 
Looks like trading is disabled at server side. Can you open manually?
 
Is the market open?
 
fexception:

Hello All!

I've been watching a lot of tutorials on how to make scripts and EA's and I'm having an issue trying to get my EA to place a buy order on the market as a test. I get the following error. I do have it in the EA folder and I have allowed live trading when the inputs screen comes up.

2019.03.24 21:56:52.092               '11123847': order buy 0.01 EURUSD opening at market sl: 1.12944 tp: 1.12964 failed [Trade is disabled]


The following is my code. 

Thoughts?

Check all the settings for "enable trading" on the MT4 platform under settings and on the ea itself ?
 
andrew4789:
Check all the settings for "enable trading" on the MT4 platform under settings and on the ea itself ?

I found out what it was. I asked the broker directly. It is an ECN account so the symbols are named XXX/YYY_ecn. In my script I didn't have "_ecn" when specifying the symbol. This corrected the issue for me. (i dont even know what ecn is. lol)


Thanks!

Reason: