This cross-platform allows working with a virtual trading environment in one of the easiest ways.
The library allows creating a virtual trading environment and trade as if it is a real trading environment. The library functionality is not new, although provided cross-platform library features one property that may be important at times: you do not need to study anything to use. Knowing MT4 (not MT5) trading logic is sufficient.
MT4-style trading logic was selected for virtual trading since it is more convenient and allows developing cross-platform EAs with ease.
The library functionality can traditionally be demonstrated by an example prepared in advance.
// Launching TS in real and virtual trading environments #include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 #include <fxsaber\Virtual\Virtual.mqh> // Virtual trading environment input double Lots = 1; input int Interval = 100; // Position lifetime input bool Example = true; // What code example to select // Reversal TS void System() { if (!OrderSelect(OrdersTotal() - 1, SELECT_BY_POS)) OrderSend(_Symbol, OP_BUY, Lots, SymbolInfoDouble(_Symbol, SYMBOL_ASK), 100, 0, 0); // If there is no position, open one else if (TimeCurrent() - OrderOpenTime() > Interval) // If the position lifetime exceeds the specified time { // Reverse the position OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 100); OrderSend(_Symbol, 1 - OrderType(), Lots, OrderClosePrice(), 100, 0, 0); } } void OnTick() { static const int handle = VIRTUAL::Create(); // Virtual trading environment handle created. 0 - real trading environment if (Example) { if (VIRTUAL::SelectByHandle()) // Real trading environment selected System(); // Launching TS on a selected trading environment (real) if (VIRTUAL::SelectByHandle(handle)) // Virtual trading environment selected { VIRTUAL::NewTick(); // Added tick to the virtual trading environment System(); // Launching TS on a selected trading environment (virtual) } } else // Alternative fixation of the same actions. // Move along all existing trading environments for (int i = 0; i <= VIRTUAL::Total(); i++) if (VIRTUAL::SelectByIndex(i)) // Selected appropriate trading environment { VIRTUAL::NewTick(); // Added tick to a selected trading environment System(); // Launching TS on a selected trading environment } Comment(VIRTUAL::ToString()); // Display the status of the virtual trading environment on the chart }
This is a cross-platform reversal EA. Its trading logic can be described in just a few strings (System function) thanks to MT4 style. The EA launches TS in real and virtual trading environments simultaneously. This can be well seen in the MT4 or MT5 Tester (CTRL+F5)

The screenshot shows that trading in real and virtual environments is identical.
Note that TS code remains the same. Only a trading environment is selected: a real one or any number of virtual ones.
The code displayed here is redundant - the two versions simply show the logic of working with the library.
Since the Tester acceleration scenario (see p. 5 above) may be required more often than others, we have added the ability to switch any TS to a virtual environment and back by adding two strings at the beginning of the code.
#define VIRTUAL_TESTER // Launch in the virtual trading environment #include <fxsaber\Virtual\Virtual.mqh> // Virtual trading environment
The highlighted string allows users not to interfere with the TS original code.

This mode has been made specifically for the Tester. It is assumed that a long-term Optimization is started with the enabled (VirtualTester = true) virtual environment instead of a real one. This provides a significant gain in Optimization speed (time). The obtained results (OnTester criterion - Balance) can then be used for standard single runs in real trading environment (VirtualTester = false).
The same two strings intended to accelerate the Tester allows solving another common problem - TS reversal.

ReverseDeals = true mode enables reversal of deals. The internal algorithm is as follows:
Thus, the EA logic is not violated in any way. At the same, we can see what the TS reversal provides. This mode is also meant for the Tester.
MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/22577
MAMy Expert
MAMy v.3 indicator-based EA
TrendLineAlert_V2
The indicator displays a sloping trend line. Its parameters are set when the indicator is launched by a trader. The trend line defines the signal trigger level. The trend line breakthrough activates signals accompanied by emails and push notifications.