Help with my first really simple EA..........

 

Can someone please tell me why this gets and error 4109 - "trade not allowed" on the demo account I set up?

//+------------------------------------------------------------------+
//| Test.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"


#define MAGICMA 7797426

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
Print (" T E S T T E S T T E S T T E S T T E S T T E S T T E S T");
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
Print ("Entering Trade");
OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"",MAGICMA,0,Red);
Print ("ERROR ERROR ERROR => ", GetLastError());
return(0);
}

 

1. See Tools - Options - Expert Advisors Tab settings.

2. Make sure the "Expert Advisors" button on the tool bar is pressed

3. Dealer may not allow EA. Pick another Dealer, or talk to the one you have.

 
phy wrote >>

1. See Tools - Options - Expert Advisors Tab settings.

2. Make sure the "Expert Advisors" button on the tool bar is pressed

3. Dealer may not allow EA. Pick another Dealer, or talk to the one you have.

Tried it at both FXDD and ODL - tab setting was set to allow EA's - the EA compiled, loaded and executed and printed my tracking print messages in Expert log, including the results of GetLastError showing error 4109. I'm baffled! This is basically right out of the tutorial. Would it be possible for you to copy the code provided into an EA and see if it does the same at your dealer. I'd be happy to switch to that dealer. Thanks and best regards - Ron!

 

Your code works.

Recheck all settings, restart MT4.

 
phy wrote >>

Your code works.

Recheck all settings, restart MT4.

Incredible! Thank you so much!!!!!!!!! I couldn't see how it couldn't being so simple.

 
Some setting changes may require restart. Don't know.
 
phy wrote >>
Some setting changes may require restart. Don't know.

I uninstalled the platform and deleted all related files and folders. Downloaded Meta4 Build 220 from FXDD and reinstalled test EA. Compiled it, activated EA capability, shut all charts except EURUSD and attached test EA. In Expert log it printed "TESTTESTTEST" followed by multiple "Entering Trade" and "ERROR ERROR ERROR 4109" until I removed EA. Any additional suggestions would be greatly appreciated. Very frustrated.

 

Did you restart MT4 after changing the settings on Tools - Options - Expert Advisors tab?

I don't know if restart is required or not.

Reason: