Download MetaTrader 5
To add comments, please log in or register
Do you have Linux? Find out how to install MetaTrader on it!
mianhae71 2014.06.13 08:12 


 I would like to ask question regarding to error 4109 when i try to use the function OrderSend. I keep getting this error even though i checked the 'Allow live trading' tickbox. Do someone know? I'm a newbie to MQL 4 coding so please bare with me =)

 Here's the code by the way.

 I just put the alerts to check the parameter i passed. Also if you know how can i concatenate the Alerts because it takes too much line just to check the parameters. I'm curious also/ 


input double   Input1=0.01;


//| Script program start function                                    |


void OnStart()


string CP = Symbol();

double lot=Input1;

double win_price=WindowPriceOnDropped();

string comment = "Buy Limit";

double stop = 0.0;

double TP = win_price + 0.0015;

Alert ("Requesting order…");

int ticket = OrderSend(CP,OP_BUYLIMIT,lot,win_price,3,stop,TP,comment,0,0,clrNONE);

Alert (CP);


Alert (lot);

Alert (win_price);

Alert (stop);

Alert (TP);

Alert (comment);

Alert (ticket);

if (ticket>0)

{ Alert ("Buy limit order successful!"); }

int Error = GetLastError();

      switch(Error)                             // Critical errors


case 2 : Alert("Common error.");

break;                              // Exit 'switch'

case 5 : Alert("Outdated version of the client terminal.");

break;                              // Exit 'switch'

case 64: Alert("The account is blocked.");

break;                              // Exit 'switch'

case 133:Alert("Trading forbidden");

break;                              // Exit 'switch'

default: Alert("Occurred error ",Error);// Other alternatives   


Alert (" Script Ended ");




Drazen Penic
Drazen Penic 2014.06.13 10:00  

 Does you indicator icon shows smiley face?   

#define ERR_TRADE_NOT_ALLOWED                      4109

 Check that you have auto trading enabled at terminal level. 


 Auto trading icon

mianhae71 2014.06.13 11:00  

Thanks drazen

Enabling the auto trading helps! hahaha! It works fine now. Very thankful! =))


what do you mean by smiley face? how will it affect scripts? 

Drazen Penic
Drazen Penic 2014.06.13 11:24  

In the upper right corner of the chart, there is active expert name and small icon that shows trading status.

If it smiles, trading is enabled:


If it is sad, trading is disabled:



Scripts will behave same as EA's - according to global trading status and to the status that can be changed through parameters form.

Check Tools -> Options -> Expert Advisors for situations where trading can be automatically disabled (e.g when you change account,  profile or even symbol on chart). Those options, if enabled, turn off "Autotrading" button. 

mianhae71 2014.06.13 12:00  

what do you mean by when symbol or period has been change it will disable trading? 

Does that mean that when i click on another period or another chart symbol. it will not trade? but that only only applies on EA right?  

mianhae71 2014.06.13 12:05  
I get it now drazen. I have seen that it disable trade after clicking on another period. how can i activate it again when it happens? Do i need to load EA again? 
Drazen Penic
Drazen Penic 2014.06.13 12:19  

You don't need to reload EA, just click on AutoTrading button.


You can go to options and change this behavior if you want (think about it carefully). 

Click on menu: Tools -> Options -> Expert Advisors 

You will see this:


 Above are settings I use - disable trading when account is changed, just to be sure I do not have some EA trading on the wrong account.

mianhae71 2014.06.13 12:37  
Ok drazen I get it now. Thanks btw =)
To add comments, please log in or register