OrderSend - error 4059 ERR_FUNCTION_NOT_ALLOWED_IN_TESTING_MODE - page 2

 
serdan:

sorry but my english is not good when i change this parameter works well

but if i change it, didnt work


Add this line to your code . . . you are not reporting errors correctly . . . run this code and report back here with the result from the tester.log file/from the journal . . .

if( AccountFreeMargin() > 0 ){
                        TicketNumber=OrderSend( Symbol(), OP_BUY, LotSize, Ask, 3, NormalizeDouble(Ask-(StopLoss*pips),Digits), NormalizeDouble(Ask+(TakeProfit*pips),Digits), CommentName, MAGIC,0,Green);
                        if(TicketNumber==-1)
                           {
                           Print("openPosition() Error opening BUY order SMA4 >= SMA9, Error# ", GetLastError() );   //  <---  add this line
                           logError("openPosition()", "Error opening BUY order SMA4 >= SMA9");
                           }
 
11:19:37 Prueba EURUSD,M15: loaded successfully
11:19:37 TestGenerator: current spread 17 used
11:19:39 Prueba inputs: LotSize=0.01; MaxtotalTrades=1500; MinProfit=0.7; MinProfitAd=0.1; CountDays=2; TrailingStop=10; 
SignalRSIhigh=60; SignalRSImiddle=50; SignalRSIlow=40; 
11:19:40 2013.07.01 17:15  Prueba EURUSD,M15: OrderSend error 130
11:19:40 2013.07.01 17:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:41 2013.07.02 09:45  Prueba EURUSD,M15: OrderSend error 130
11:19:41 2013.07.02 09:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:42 2013.07.03 05:00  Prueba EURUSD,M15: OrderSend error 130
11:19:42 2013.07.03 05:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:43 2013.07.03 13:45  Prueba EURUSD,M15: OrderSend error 130
11:19:43 2013.07.03 13:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:44 2013.07.04 01:00  Prueba EURUSD,M15: OrderSend error 130
11:19:44 2013.07.04 01:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:45 2013.07.04 10:30  Prueba EURUSD,M15: OrderSend error 130
11:19:45 2013.07.04 10:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:46 2013.07.05 07:30  Prueba EURUSD,M15: OrderSend error 130
11:19:46 2013.07.05 07:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:49 2013.07.08 20:30  Prueba EURUSD,M15: OrderSend error 130
11:19:49 2013.07.08 20:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:49 2013.07.09 01:15  Prueba EURUSD,M15: OrderSend error 130
11:19:49 2013.07.09 01:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:51 2013.07.10 00:30  Prueba EURUSD,M15: OrderSend error 130
11:19:51 2013.07.10 00:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:55 2013.07.11 11:15  Prueba EURUSD,M15: OrderSend error 130
11:19:55 2013.07.11 11:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:56 2013.07.11 19:45  Prueba EURUSD,M15: OrderSend error 130
11:19:56 2013.07.11 19:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:56 2013.07.12 04:45  Prueba EURUSD,M15: OrderSend error 130
11:19:56 2013.07.12 04:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:57 2013.07.12 16:30  Prueba EURUSD,M15: OrderSend error 130
11:19:57 2013.07.12 16:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:58 2013.07.15 01:45  Prueba EURUSD,M15: OrderSend error 130
11:19:58 2013.07.15 01:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:58 2013.07.15 03:30  Prueba EURUSD,M15: OrderSend error 130
11:19:58 2013.07.15 03:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:59 2013.07.15 16:30  Prueba EURUSD,M15: OrderSend error 130
11:19:59 2013.07.15 16:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:19:59 2013.07.16 01:15  Prueba EURUSD,M15: OrderSend error 130
11:19:59 2013.07.16 01:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:00 2013.07.16 10:00  Prueba EURUSD,M15: OrderSend error 130
11:20:00 2013.07.16 10:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:02 2013.07.17 09:45  Prueba EURUSD,M15: OrderSend error 130
11:20:02 2013.07.17 09:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:02 2013.07.17 12:30  Prueba EURUSD,M15: OrderSend error 130
11:20:02 2013.07.17 12:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:03 2013.07.18 00:00  Prueba EURUSD,M15: OrderSend error 130
11:20:03 2013.07.18 00:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:04 2013.07.18 12:00  Prueba EURUSD,M15: OrderSend error 130
11:20:04 2013.07.18 12:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:05 2013.07.18 23:15  Prueba EURUSD,M15: OrderSend error 130
11:20:05 2013.07.18 23:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:05 2013.07.19 09:30  Prueba EURUSD,M15: OrderSend error 130
11:20:05 2013.07.19 09:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:06 2013.07.19 16:15  Prueba EURUSD,M15: OrderSend error 130
11:20:06 2013.07.19 16:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:07 2013.07.22 07:45  Prueba EURUSD,M15: OrderSend error 130
11:20:07 2013.07.22 07:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:08 2013.07.23 00:15  Prueba EURUSD,M15: OrderSend error 130
11:20:08 2013.07.23 00:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:09 2013.07.23 16:00  Prueba EURUSD,M15: OrderSend error 130
11:20:09 2013.07.23 16:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:10 2013.07.24 09:00  Prueba EURUSD,M15: OrderSend error 130
11:20:10 2013.07.24 09:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:11 2013.07.24 17:45  Prueba EURUSD,M15: OrderSend error 130
11:20:11 2013.07.24 17:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:13 2013.07.26 03:30  Prueba EURUSD,M15: OrderSend error 130
11:20:13 2013.07.26 03:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:15 2013.07.26 17:00  Prueba EURUSD,M15: OrderSend error 130
11:20:15 2013.07.26 17:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:15 2013.07.26 22:00  Prueba EURUSD,M15: OrderSend error 130
11:20:15 2013.07.26 22:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:15 2013.07.29 03:15  Prueba EURUSD,M15: OrderSend error 130
11:20:15 2013.07.29 03:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:17 2013.07.29 20:15  Prueba EURUSD,M15: OrderSend error 130
11:20:17 2013.07.29 20:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:18 2013.07.30 18:45  Prueba EURUSD,M15: OrderSend error 130
11:20:18 2013.07.30 18:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:19 2013.07.31 02:00  Prueba EURUSD,M15: OrderSend error 130
11:20:19 2013.07.31 02:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:19 2013.07.31 04:15  Prueba EURUSD,M15: OrderSend error 130
11:20:19 2013.07.31 04:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:19 2013.07.31 09:15  Prueba EURUSD,M15: OrderSend error 130
11:20:19 2013.07.31 09:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:20 2013.07.31 16:15  Prueba EURUSD,M15: OrderSend error 130
11:20:20 2013.07.31 16:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:21 2013.07.31 23:30  Prueba EURUSD,M15: OrderSend error 130
11:20:21 2013.07.31 23:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:21 2013.08.01 03:30  Prueba EURUSD,M15: OrderSend error 130
11:20:21 2013.08.01 03:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:23 2013.08.01 23:30  Prueba EURUSD,M15: OrderSend error 130
11:20:23 2013.08.01 23:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:23 2013.08.02 02:45  Prueba EURUSD,M15: OrderSend error 130
11:20:23 2013.08.02 02:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:24 2013.08.02 11:30  Prueba EURUSD,M15: OrderSend error 130
11:20:24 2013.08.02 11:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:25 2013.08.02 22:15  Prueba EURUSD,M15: OrderSend error 130
11:20:25 2013.08.02 22:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:26 2013.08.05 08:45  Prueba EURUSD,M15: OrderSend error 130
11:20:26 2013.08.05 08:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:27 2013.08.05 22:15  Prueba EURUSD,M15: OrderSend error 130
11:20:27 2013.08.05 22:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:27 2013.08.05 23:45  Prueba EURUSD,M15: OrderSend error 130
11:20:27 2013.08.05 23:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:27 2013.08.06 02:15  Prueba EURUSD,M15: OrderSend error 130
11:20:27 2013.08.06 02:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:29 2013.08.06 21:45  Prueba EURUSD,M15: OrderSend error 130
11:20:29 2013.08.06 21:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:29 2013.08.07 00:30  Prueba EURUSD,M15: OrderSend error 130
11:20:29 2013.08.07 00:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:30 2013.08.07 14:30  Prueba EURUSD,M15: OrderSend error 130
11:20:30 2013.08.07 14:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:31 2013.08.08 02:15  Prueba EURUSD,M15: OrderSend error 130
11:20:31 2013.08.08 02:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:31 2013.08.08 05:45  Prueba EURUSD,M15: OrderSend error 130
11:20:31 2013.08.08 05:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:32 2013.08.08 15:15  Prueba EURUSD,M15: OrderSend error 130
11:20:32 2013.08.08 15:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:33 2013.08.09 03:15  Prueba EURUSD,M15: OrderSend error 130
11:20:33 2013.08.09 03:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:34 2013.08.09 11:00  Prueba EURUSD,M15: OrderSend error 130
11:20:34 2013.08.09 11:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:36 2013.08.12 16:30  Prueba EURUSD,M15: OrderSend error 130
11:20:36 2013.08.12 16:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:36 2013.08.12 22:15  Prueba EURUSD,M15: OrderSend error 130
11:20:36 2013.08.12 22:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:38 2013.08.14 00:45  Prueba EURUSD,M15: OrderSend error 130
11:20:38 2013.08.14 00:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:38 2013.08.14 04:15  Prueba EURUSD,M15: OrderSend error 130
11:20:38 2013.08.14 04:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:38 2013.08.14 06:45  Prueba EURUSD,M15: OrderSend error 130
11:20:38 2013.08.14 06:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:38 2013.08.14 09:15  Prueba EURUSD,M15: OrderSend error 130
11:20:38 2013.08.14 09:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:39 2013.08.14 17:30  Prueba EURUSD,M15: OrderSend error 130
11:20:39 2013.08.14 17:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:40 2013.08.14 20:30  Prueba EURUSD,M15: OrderSend error 130
11:20:40 2013.08.14 20:30  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:40 2013.08.15 09:00  Prueba EURUSD,M15: OrderSend error 130
11:20:40 2013.08.15 09:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:40 2013.08.15 11:15  Prueba EURUSD,M15: OrderSend error 130
11:20:40 2013.08.15 11:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:42 2013.08.16 10:45  Prueba EURUSD,M15: OrderSend error 130
11:20:42 2013.08.16 10:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:45 2013.08.20 02:00  Prueba EURUSD,M15: OrderSend error 130
11:20:45 2013.08.20 02:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:45 2013.08.20 05:00  Prueba EURUSD,M15: OrderSend error 130
11:20:45 2013.08.20 05:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:46 2013.08.20 21:00  Prueba EURUSD,M15: OrderSend error 130
11:20:46 2013.08.20 21:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:46 2013.08.21 02:15  Prueba EURUSD,M15: OrderSend error 130
11:20:46 2013.08.21 02:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:47 2013.08.21 05:00  Prueba EURUSD,M15: OrderSend error 130
11:20:47 2013.08.21 05:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:47 2013.08.21 07:00  Prueba EURUSD,M15: OrderSend error 130
11:20:47 2013.08.21 07:00  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:48 2013.08.21 21:15  Prueba EURUSD,M15: OrderSend error 130
11:20:48 2013.08.21 21:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:49 2013.08.22 09:45  Prueba EURUSD,M15: OrderSend error 130
11:20:49 2013.08.22 09:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:50 2013.08.22 22:15  Prueba EURUSD,M15: OrderSend error 130
11:20:50 2013.08.22 22:15  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:51 2013.08.23 03:45  Prueba EURUSD,M15: OrderSend error 130
11:20:51 2013.08.23 03:45  Prueba EURUSD,M15: openPosition() Error opening BUY order SMA4 >= SMA9, Error# 4059
11:20:51 2013.08.23 10:00  Prueba EURUSD,M15: OrderSend error 130
 
serdan:
Can you please confirm the Build/Version of MT4 that you are using . . .
 

ironfx metatrader 4 version: 4.00 build 509 (24 jun 2013)

 
serdan:

ironfx metatrader 4 version: 4.00 build 509 (24 jun 2013)

From the code you have shown I do not see how you are getting error 4059 and not error 130 . . . you are getting error 130 as you can see but the code you have shown should be reporting error 130 too.

In any case you should fix the error 130, you should verify, in code, that the trade you are planning to execute complies with these requirements: Requirements and Limitations in Making Trades the ideal situation is that you prevent placing Orders that will produce error 130.
 
Don't do this.
void logError(string functionName, string msg, int errorCode = -1)
  {
    Print("ERROR: in " + functionName + "()");
    Print("ERROR: " + msg );
    
    int err = GetLastError();
    if(errorCode != -1) 
        err = errorCode;
You MUST get the error IMMEDIATELY after your function returns an error. NO interceding functions which can overwrite the value.
void logError(string functionName, string msg, int err = -1)
  {
    if(err == -1) err = GetLastError();
    Print("ERROR: in " + functionName + "()");
    Print("ERROR: " + msg );
:
 

thanks for your help!