Discussion of article "The checks a trading robot must pass before publication in the Market" - page 10

 

Hi, I am trying to upload an EA, but I always get the same error

test on EURUSD,H1 (hedging)
 2022.02.03 15:40:40   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13260, tp: 1.13310 [Invalid stops]
 2022.02.03 15:40:59   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13225, tp: 1.13310 [Invalid stops]
 2022.02.03 15:41:00   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13225, tp: 1.13310 [Invalid stops]
 2022.02.03 15:41:20   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13240, tp: 1.13310 [Invalid stops]
 2022.02.03 15:41:40   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13155, tp: 1.13310 [Invalid stops]
 2022.02.03 15:41:59   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13210, tp: 1.13310 [Invalid stops]
 2022.02.03 15:42:00   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13210, tp: 1.13310 [Invalid stops]
 2022.02.03 15:42:20   failed modify #11 buy 0.55 EURUSD sl: 1.12910, tp: 1.13310 -> sl: 1.13210, tp: 1.13310 [Invalid stops]
 2022.02.08 09:13:40   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14035, tp: 1.13945 [Invalid stops]
 2022.02.08 09:13:59   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14055, tp: 1.13945 [Invalid stops]
 2022.02.08 09:14:00   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14055, tp: 1.13945 [Invalid stops]
 2022.02.08 09:14:20   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14065, tp: 1.13945 [Invalid stops]
 2022.02.08 09:14:40   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14030, tp: 1.13945 [Invalid stops]
 2022.02.08 09:14:59   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14035, tp: 1.13945 [Invalid stops]
 2022.02.08 09:15:00   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14035, tp: 1.13945 [Invalid stops]
 2022.02.08 09:15:20   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14040, tp: 1.13945 [Invalid stops]
 2022.02.08 09:15:40   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.13985, tp: 1.13945 [Invalid stops]
 2022.02.08 09:15:59   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14025, tp: 1.13945 [Invalid stops]
 2022.02.08 09:16:00   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14025, tp: 1.13945 [Invalid stops]
 2022.02.08 09:16:20   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14025, tp: 1.13945 [Invalid stops]
 2022.02.08 09:16:40   failed modify #21 sell 0.55 EURUSD sl: 1.14345, tp: 1.13945 -> sl: 1.14050, tp: 1.13945 [Invalid stops]
strategy tester report 100 total trades

I run the same test locally but I don't get any errors. What could be happening to cause these errors? 

2025.02.01 11:34:52.756 2022.02.03 15:40:26   Ticket #4#  
2025.02.01 11:34:52.756 2022.02.03 15:40:26   new stopLoss: 1.1313000000000002
2025.02.01 11:34:52.756 2022.02.03 15:40:26   position modified [#4 buy 0.55 EURUSD 1.13081 sl: 1.13130 tp: 1.13280]
2025.02.01 11:34:52.758 2022.02.03 15:40:26   CTrade::OrderSend: modify position #4 EURUSD (sl: 1.13130, tp: 1.13280) [done]
2025.02.01 11:34:52.759 2022.02.03 15:40:27   Ticket #4#  
2025.02.01 11:34:52.759 2022.02.03 15:40:27   new stopLoss: 1.1314000000000002
2025.02.01 11:34:52.759 2022.02.03 15:40:27   position modified [#4 buy 0.55 EURUSD 1.13081 sl: 1.13140 tp: 1.13280]
2025.02.01 11:34:52.761 2022.02.03 15:40:27   CTrade::OrderSend: modify position #4 EURUSD (sl: 1.13140, tp: 1.13280) [done]
2025.02.01 11:34:52.763 2022.02.03 15:40:28   Ticket #4#  
2025.02.01 11:34:52.763 2022.02.03 15:40:28   new stopLoss: 1.13145
2025.02.01 11:34:52.763 2022.02.03 15:40:28   position modified [#4 buy 0.55 EURUSD 1.13081 sl: 1.13145 tp: 1.13280]
2025.02.01 11:34:52.765 2022.02.03 15:40:28   CTrade::OrderSend: modify position #4 EURUSD (sl: 1.13145, tp: 1.13280) [done]
2025.02.01 11:34:52.765 2022.02.03 15:40:28   Ticket #4#  
2025.02.01 11:34:52.765 2022.02.03 15:40:28   new stopLoss: 1.13155
2025.02.01 11:34:52.767 2022.02.03 15:40:28   position modified [#4 buy 0.55 EURUSD 1.13081 sl: 1.13155 tp: 1.13280]
2025.02.01 11:34:52.769 2022.02.03 15:40:28   CTrade::OrderSend: modify position #4 EURUSD (sl: 1.13155, tp: 1.13280) [done]
2025.02.01 11:34:52.770 2022.02.03 15:40:29   Ticket #4#  
2025.02.01 11:34:52.770 2022.02.03 15:40:29   new stopLoss: 1.1316000000000002
2025.02.01 11:34:52.770 2022.02.03 15:40:29   position modified [#4 buy 0.55 EURUSD 1.13081 sl: 1.13160 tp: 1.13280]
2025.02.01 11:34:52.772 2022.02.03 15:40:29   CTrade::OrderSend: modify position #4 EURUSD (sl: 1.13160, tp: 1.13280) [done]
 
Francisco Jesus Alonso Martin #:

Hi, I am trying to upload an EA, but I always get the same error

I run the same test locally but I don't get any errors. What could be happening to cause these errors? 

Ok, I have solved it, I had to check the stop levels against the price.

 

Hello, me again.

I only have one error left but I can't find the solution to this one.

test on XAUUSD,D1 (hedging)
 2022.07.12 04:30:40   current account state: Balance: 1126.50, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 1126.50, Margin: 0.00, FreeMargin: 1126.50
 2022.07.12 04:30:40   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 1126.50, Margin: 1132.76, FreeMargin: -6.26
 2022.07.12 04:30:40   not enough money for order [#7 buy stop 0.65 XAUUSD at 1742.70]
strategy tester report 13 total trades

I am always checking the margin I have before doing any buy or sell with this method:

bool checkMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type) {
//--- Getting the opening price
    MqlTick mqltick;
    SymbolInfoTick(symb,mqltick);
    double price = mqltick.ask;
    if(type == ORDER_TYPE_SELL)
        price = mqltick.bid;
//--- values of the required and free margin
    double margin,free_margin = AccountInfoDouble(ACCOUNT_MARGIN_FREE);
    //--- call of the checking function
    if(!OrderCalcMargin(type,symb,lots,price,margin)) {
        //--- something went wrong, report and return false
        Print("Error in ",__FUNCTION__," code=",GetLastError());
        return(false);
    }
    //--- if there are insufficient funds to perform the operation
    if(margin > free_margin || free_margin < 0) {
        //--- report the error and return false
        Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
        return(false);
    }
//--- checking successful
    return(true);
}
 

 got error in validation process that i cant find that when i got back test on mqlf5 on that date no error in my terminal

no error