Need wise counsel

 

I'm a beginner in auto-trading and need assistance getting started

Have copied very simple buy (or sell) code from user manual, have successfully compiled, but cannot get it initiated after dragging to open window

Code:

int start()
{
OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Ask+10*Point,Ask-20*Point);
return;
}

Platform response:

2010.07.16 16:22:52 SimpleSell3 EURJPY.,M1: loaded successfully
2010.07.16 16:22:52 SimpleSell3 EURJPY.,M1: uninit reason 0
2010.07.16 16:22:52 SimpleSell3 EURJPY.,M1: removed

Assistance very much appreciated

Ben

 

try:

int start()
{
   int Ticket;
   Ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Ask+10*Point,Ask-20*Point);
   
   if(Ticket>0)
      {
        Print("OrderSend OK");
        return(0);        
      }
   
   Print("OrderSend failed with error #",GetLastError());   
   return(0);
}

and se what error you get.

 

I prefer to catch the error number (if any) right away, as this is could be changed by anything occurring later

int start()
{
   int Ticket, iOrderError;

   Ticket=OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Ask+10*Point,Ask-20*Point);

   iOrderError = GetLastError();
   
   if(Ticket>0)
      {
        Print("OrderSend OK");
        return(0);        
      }
   
   Print("OrderSend failed with error #", iOrderError);   
   return(0);
}

-BB-

 

Many thanks to enotrek and BarrowBoy

Both recommendations produced the same results:

2010.07.16 23:41:18 SimpleSell5 EURJPY.,M1: OrderSend failed with error #4109

ERR_TRADE_NOT_ALLOWED (4109)

Error description is not helping me much -- any experience with this error?

Ben

 

D

ERR_TRADE_NOT_ALLOWED4109Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties.
 
Also not that once you enable it, the code above will try to send one order per tick.
 

Here's some links for error codes. bookmark it! You'll need it quite often in the beginning in your programming career =).

I did, and is still doing.


https://docs.mql4.com/constants/errors

and here's some more

https://docs.mql4.com/runtime/errors


Enotrek

 
enotrek:

Here's some links for error codes. bookmark it! You'll need it quite often in the beginning in your programming career =).

I did, and is still doing.


https://docs.mql4.com/constants/errors

and here's some more

https://docs.mql4.com/runtime/errors


Enotrek


Many thanks, very useful information!
 
BarrowBoy:

D

ERR_TRADE_NOT_ALLOWED 4109 Trade is not allowed. Enable checkbox "Allow live trading" in the expert properties.

Many thanks, can now access error codes
 
enotrek:

Here's some links for error codes. bookmark it! You'll need it quite often in the beginning in your programming career =).

I did, and is still doing.


https://docs.mql4.com/constants/errors

and here's some more

https://docs.mql4.com/runtime/errors


Enotrek


Have had first successful auto-trades, very pleased

Many thanks again to enotrek, BarrowBoy and WHRoeder for making the difference

Ben

Reason: