test_script

Download script
Author: Copyright � 2005, Serega Lykov
Profit factor:
10.10

This script serves as a diagnostic tool designed to test how the trading platform handles various common errors and edge cases when managing orders. Rather than executing a specific trading strategy, it systematically triggers different scenarios to observe how the system responds to "problematic" instructions.

The logic is divided into four distinct testing phases:

Phase 1: Handling Invalid Identifiers The script attempts to scan through a massive list of order IDs. It purposefully seeks out an order that does not exist and tries to delete it. This tests how the platform reports errors when you try to perform an action on a "ghost" ticket—essentially checking if the system correctly identifies and logs an invalid request.

Phase 2: Lifecycle of a Live Trade In this section, the script simulates a standard trading workflow. It opens a new buy position at the current market price and immediately attempts to close it. Once the trade is closed, it tries to remove the record from the active list. This validates that the transition from an "Open Trade" to a "Closed Trade" is handled smoothly by the software.

Phase 3: Handling Extreme Price Data This test pushes the boundaries of the system by attempting to open a trade at an unrealistic price point (an extremely high value). Because this price is far outside of normal market limits, the order will fail to be placed. The script then tries to delete that failed request to see how the platform manages "non-existent" orders created by invalid price data.

Phase 4: Market Order Restrictions Finally, the script tests the rules regarding "Market Orders." In many trading environments, certain types of orders cannot be deleted while they are still active; they must be closed first. The script attempts to delete an open order directly. If the platform prevents this (which is standard behavior), the script is designed to recognize that failure and automatically switch to a "Close" command instead.

Summary for Users Think of this script as a "stress test." It intentionally creates various types of mistakes—such as trying to delete things that aren't there, using impossible prices, or ignoring standard closing procedures—to ensure the platform logs these errors correctly and remains stable under irregular conditions.

Orders Execution
It automatically opens orders when conditions are reachedIt Closes Orders by itself
14 Views
0 Downloads
0 Favorites
test_script
//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                                   Copyright © 2005, Serega Lykov |
//|                                       http://mtexperts.narod.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Serega Lykov"
#property link      "http://mtexperts.narod.ru/"

int start()
  {
//---- OrderSelect() = false -----------------------------------------
//     return error: 4051 (ERR_INVALID_FUNCTION_PARAMVALUE)
//     message at logs: invalid ticket for OrderDelete function
   Print("1. ------------------------------------------------------");
   for(int i=1; i<100000; i++)
     {
      if(OrderSelect(i,SELECT_BY_TICKET) == true) continue;
      bool error = OrderDelete(OrderTicket(),CLR_NONE);
      if(error == false) Print("Error = ",GetLastError());
      break;
     } 
//---- delete order from history -------------------------------------
//     return error: 4108 (ERR_INVALID_TICKET)
//     message at logs: unknown ticket 24858529 for OrderDelete function
   Print("2. ------------------------------------------------------");
   int ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",0,0,CLR_NONE);
   OrderClose(ticket,0.01,Bid,10,CLR_NONE);
   if(OrderSelect(ticket,SELECT_BY_TICKET) == true)
     {
      error = OrderDelete(OrderTicket(),CLR_NONE);
      if(error == false) Print("Error = ",GetLastError());
     }
//---- OrderSend() < 0  ----------------------------------------------
//     return error: 4051 (ERR_INVALID_FUNCTION_PARAMVALUE)
//     message at logs: invalid ticket for OrderDelete function
   Print("3. ------------------------------------------------------");
   ticket = OrderSend(Symbol(),OP_BUY,0.01,100000,3,0,0,"",0,0,CLR_NONE);
   error = OrderDelete(ticket,CLR_NONE);
   if(error == false) Print("Error = ",GetLastError()); 
//---- delete market order -------------------------------------------
//     return error: 4108 (ERR_INVALID_TICKET)
//     message at logs: market order #24859072 cannot be deleted
   Print("4. ------------------------------------------------------");
   ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,"",0,0,CLR_NONE);
   error = OrderDelete(ticket,CLR_NONE);
   if(error == false)
     {
      Print("Error = ",GetLastError());
      OrderClose(ticket,0.01,Bid,10,CLR_NONE);
     }
   return(0);
  }
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
26 reports
USD/CAD Oct 2024 - Jan 2025
177.61
Total Trades 1499
Won Trades 500
Lost trades 999
Win Rate 33.36 %
Expected payoff 20.01
Gross Profit 30163.56
Gross Loss -169.83
Total Net Profit 29993.73
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
57.28
Total Trades 1499
Won Trades 500
Lost trades 999
Win Rate 33.36 %
Expected payoff 4.50
Gross Profit 6867.32
Gross Loss -119.88
Total Net Profit 6747.44
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
14.64
Total Trades 1499
Won Trades 500
Lost trades 999
Win Rate 33.36 %
Expected payoff 1.09
Gross Profit 1755.53
Gross Loss -119.88
Total Net Profit 1635.65
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
13.13
Total Trades 1499
Won Trades 500
Lost trades 999
Win Rate 33.36 %
Expected payoff 1.05
Gross Profit 1704.80
Gross Loss -129.87
Total Net Profit 1574.93
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -6.09
Gross Profit 0.00
Gross Loss -9128.97
Total Net Profit -9128.97
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8125.68
Total Net Profit -8125.68
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -6.09
Gross Profit 0.00
Gross Loss -9125.59
Total Net Profit -9125.59
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -6.00
Gross Profit 0.00
Gross Loss -9001.45
Total Net Profit -9001.45
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -4.34
Gross Profit 0.00
Gross Loss -6500.17
Total Net Profit -6500.17
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8127.19
Total Net Profit -8127.19
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8129.13
Total Net Profit -8129.13
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8125.78
Total Net Profit -8125.78
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.01
Gross Profit 0.00
Gross Loss -7504.68
Total Net Profit -7504.68
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.59
Gross Profit 0.00
Gross Loss -8375.32
Total Net Profit -8375.32
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8130.80
Total Net Profit -8130.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8125.44
Total Net Profit -8125.44
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8128.08
Total Net Profit -8128.08
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -6.09
Gross Profit 0.00
Gross Loss -9127.85
Total Net Profit -9127.85
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -0.48
Gross Profit 0.00
Gross Loss -725.68
Total Net Profit -725.68
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.59
Gross Profit 0.00
Gross Loss -8375.28
Total Net Profit -8375.28
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 2775
Won Trades 0
Lost trades 2775
Win Rate 0.00 %
Expected payoff -0.94
Gross Profit 0.00
Gross Loss -2601.43
Total Net Profit -2601.43
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8125.16
Total Net Profit -8125.16
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -6.09
Gross Profit 0.00
Gross Loss -9127.68
Total Net Profit -9127.68
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.17
Gross Profit 0.00
Gross Loss -7753.22
Total Net Profit -7753.22
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -4.34
Gross Profit 0.00
Gross Loss -6504.21
Total Net Profit -6504.21
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.00
Total Trades 1499
Won Trades 0
Lost trades 1499
Win Rate 0.00 %
Expected payoff -5.42
Gross Profit 0.00
Gross Loss -8127.53
Total Net Profit -8127.53
-100%
-50%
0%
50%
100%

Comments