Can you help me pls? error code4109

 

Hi, 

 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 (OP_BUYLIMIT);

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 ");

return;


   

  } 

 

 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

 

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? 

 

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. 

 

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?  

 
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? 
 

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.

 
Ok drazen I get it now. Thanks btw =)