BackTest module

The BackTest module is designed for testing automated trading and practising manual trading skills using historical trade data from various exchanges. The BackTest module only works with the PRO version of the MoonBot terminal and is activated using Moon Credits.


Important! In scalping, there is no repeatability of results when replaying the same market record!

* A more detailed explanation of this will be provided at the end of the article.


In short: just as two identical MoonBot terminals with identical strategies on two different VDSs will not trade exactly the same way in the real market, two runs of historical data with the same strategy will not give exactly the same result.


Backtesting in scalping, and in particular in the MoonBot terminal, is not needed to repeat the result 1 to 1, but to see the general behaviour of strategies in various market situations and to optimise them for those situations.


The BackTest window in the MoonBot terminal is accessed via Menu - BackTest and looks as follows (examples for downloading archives from Binance Futures Daily and Gate Spot Montly exchanges):

The BackTest window consists of two main control areas:


1) The upper area, which is used for the backtesting process itself and includes the following buttons: "Select File", "Play", "Stop", "Explorer", "Scissors", as well as a progress bar for playing the .bin file. Clicking on "Help" will open this page of our website with detailed instructions on how to use the BackTest functionality.


2) The lower area, which is used to download sample .bin files, as well as to download .bin files with data from various exchanges, and includes two zones:

a) The zone with a "Download Examples" button.

b) The "Exchange archives" area: with a menu for selecting the type of exchange, a Spot or Futures menu, a menu for selecting whether to download the archive for the day (Daily) or for the entire month (Monthly), a field for selecting a coin, a menu for selecting a specific date or month, and a "Download data" button with a data download progress bar.

After clicking on the "Download data" button to the right of the download progress bar, entries will appear such as: archive download progress (Recvd 1 / 183 Mb ... Recvd 183 / 183 Mb), archive unpacking (unpack data..), data parsing by day (Parsing 01.07.2025...Parsing 31.07.2025). After all operations are successfully completed, the message "Done" will appear.

If you enter an incorrect coin name or date for which there is no archive data on the exchange, clicking the "Download data" button will display the message "Not Found", meaning that no archive data was found for download.


Data from Binance Spot can be downloaded starting from 17-08-2017 (the first available file is Binance_BTC_spot 17-08-2017.bin).

Data from Binance Futures can be downloaded starting from 01-01-2020 (the first available file is Binance_BTC_futures 01-01-2020.bin).

Data from Gate Spot can be downloaded starting from 01-01-2018 (the first available file is Gate_BTC_spot 01-01-2018.bin).

Data from Gate Futures can be downloaded starting from 18-11-2019 (the first available file is Gate_BTC_futures 18-11-2019.bin).


The lower area of the BackTest window can be hidden by clicking on the "..." button (ellipsis) for light themes or the "Hide" button for dark themes.


Backtesting is performed by playing files containing historical trade data records. Files with this data have the .bin extension. Where can you get them?


1) Click on the "Download Examples" button and download pre-prepared examples of volatile coin chart fragments with the .bin extension from our server, which will be saved in the BackTest folder (this folder is automatically created by the MoonBot terminal in its root directory). Currently, the following sample files with the .bin extension are saved in the BackTest folder:

Demo_BANANAS31 09-07-2025 10-18.bin

Demo_GMX 09-08-2025 23-14.bin

Demo_GMX 10-08-2025 06-33.bin

Demo_HAEDAL 21-05-2025 17-04.bin

Demo_LA 11-08-2025 00-39.bin

Demo_LAYER 10-08-2025 05-39.bin

Demo_REQ_05-21-04-23-57.bin

Demo_TREE_07-29-17-16-05.bin


2) Download daily archives from different exchanges in the lower area of the BackTest window (to do this, select the exchange, market, pair, day or entire month, click the "Download data" button, after which the .bin files will be downloaded and saved to the BackTest folder, in a subfolder of the form "LTC-2025-07" (coin-year-month). Data from the Binance exchange can be downloaded for a specific day (Daily) or for an entire month (Monthly), while data from the Gate exchange can only be downloaded for an entire month (Monthly).


3) You can also use ready-made .bin files from the Logs or Logs\Important folder, where they are automatically saved by the MoonBot terminal as a result of transactions in the report, i.e. when you previously opened a Important, where they are automatically saved by the MoonBot terminal as a result of transactions in the report, i.e. when you previously opened a transaction in the report in the Pump Chart window, such a .bin file from the Logs folder was used to view the transaction on the chart in static form, and now it can be used to play it on the chart through the BackTest window.


Playing back a .bin file will take exactly as long as its duration on the chart from the report if you open the .bin file from the Logs folder, or exactly 1 day if you open the downloaded .bin file from the exchange archives. Therefore, from long records of historical trade data in .bin files, you can only extract interesting and shorter fragments that will be needed for quick testing of certain strategies. To do this, click the "Explorer" button, select the .bin file in the desired folder, click OK, and it will open in static form in the Pump Chart window. Then, in the BackTest window, click the "Scissors" button, hold down the Ctrl key and left-click on the coin chart at the beginning of the first fragment, then move the mouse to the end of the second fragment, the selected area will be marked with a green rectangle, and then release the left mouse button at the final point. After that, the terminal will offer to save the selected fragment in a separate .bin file in the BackTest folder, which can then be used for backtesting.


Using the "Scissors" button, you can cut out interesting fragments in the same way and save them as .bin files on the coin charts in the main terminal window or on the charts in the Chart windows, but only before converting them into mini candles. It is impossible to play .bin files recorded on a chart where mini candles have replaced the cross trades. When attempting to play such a .bin file in the BackTest window, the message “Nothing to play!” will appear above the playback progress bar instead of the name of the loaded file.


Sequential recording and saving of multiple .bin files into one using the BackTest window:

If you have different fragments of a chart with historical data for one coin recorded at different times, for example, files BTC1.bin and BTC2.bin, you can combine them into one .bin file. To do this, perform the following operations in the BackTest window:


1) Click on the "Select File" button to select the first fragment, BTC1.bin.

2) Click on the "Play" button and play the first fragment, BTC1.bin, on the coin chart.

3) Click on the "Select File" button to select the second fragment, BTC2.bin.

4) Click on the "Play" button and play the second fragment BTC2.bin on the coin chart.

5) Click on the "Scissors" button and then, holding down the Ctrl key, left-click on the coin chart at the beginning of the first fragment, then move the mouse to the end of the second fragment, while the selected area will be marked with a green rectangular area, and then release the left mouse button at the final position.

6) After that, a window with a notification will appear in the terminal:

Warning

Store fragment of ВТС chart, interval from 14:58:37 to 15:03:06 (269 sec) to BackTest\*.bin ?

Yes / No

7) After confirming that the file has been saved, it will be saved to the BackTest\Demo_BTC 23-08-2025 14-58.bin folder.

Explanation of the symbols in the .bin file:

Demo - a prefix indicating that this is a demo file.

BTC - the name of the coin on which the historical trade data was recorded.

23-08-2025 - the date the file was saved (23 August 2025).

14-58 - the hour and minute when the file was saved (at 14 hours 58 minutes).


"Gluing" several fragments of graphs in the Pump Chart window using the BackTest window:


"Gluing" several fragments of charts is an undocumented feature in the MoonBot terminal. To do this, with the "BackTest" window open, open 2 or more .bin files with the same coin name via the Menu - Trades History or by clicking on the "Explorer" button. In this case, trades from the new file will be added to the previous chart rather than overwriting it. To "Gluing" the charts together, you need to select chart fragments without gaps. For example, if your .bin files are cut into 10-minute segments on average, you need to glue them together every 7-9 minutes.


Attention! It is not possible to play .bin files from different coins that are listed on the exchange on a single chart, and therefore it is not possible to record them sequentially or "glue" them together, i.e. each .bin file will be played strictly on the chart of its own coin.


If both .bin files belong to coins that have been removed from the exchange, for example Coin1Delist.bin and Coin2Delist.bin, then they can be played on the ETH market and, accordingly, the data from them can be recorded sequentially or "glued" together, since the ETH coin chart is always used to play .bin files of delisted coins.


After completing the preparation of .bin files with historical trade data, for convenience, you can collapse the lower area of the BackTest window using the "..." or "Hide" button and leave only the upper area for loading and playing .bin files for backtesting.


Starting the backtest procedure (using a demo file from the MoonBot terminal collection as an example):


In the main window of the MoonBot terminal, click on Menu - BackTest to open the "BackTest" window.


Click on the "Download Examples" button, and examples from the MoonBot terminal collection will be downloaded to the BackTest folder.


Click on the "Select File" button, the explorer will open, select a demo .bin file in the BackTest folder, for example Demo_LA 11-08-2025 00-39.bin, and click OK. The name of this file will appear in the BackTest window.


Prepare and activate the strategies that will participate in the backtest, enable the general "EMULATION" mode in the terminal via Menu - Emulation mode and the Autodetect: ON button.


Click the "Play" button in the BackTest window.


The playback of historical trade data from the file Demo_LA 11-08-2025 00-39.bin will start, and the LA coin chart, the data for which was recorded in this .bin file, will open immediately. If this coin is no longer on the market, the recorded chart will always be played on the ETH coin chart.


You can monitor the progress of the .bin file playback on the scale named after the file in the BackTest window.


You can stop the .bin file playback at any time by clicking the "Stop" button in the BackTest window.


When you click the "Play" button again in the BackTest window, the previously selected .bin file will be played first.

During the playback of the .bin file, the strategies that were active and passed through the filters will be triggered. After the .bin file has finished playing, you can click the "Reports" button on the MoonBot terminal main window, open the Report Table, and evaluate the results of these strategies. If necessary, you can adjust the strategy parameters you need and run the .bin file again. Continue the testing cycle until you get the results you need.

Attention!


If the general mode in the MoonBot terminal has not been manually switched to EMULATION mode, but has accidentally remained in real mode, then after pressing the "Play" button in the BackTest window, the terminal will automatically enable protection and switch the general mode to EMULATION so that orders with real deposits are not placed during backtesting.


If, while playing a .bin file, you try to manually switch the terminal's general mode from EMULATION to real, another protection will be activated, namely, the "Stop" button will be pressed in the BackTest window, the playback of the .bin file will stop, and real trades will appear on the coin chart.


When testing strategies using the BackTest functionality in the leading MoonBot terminal, commands are not sent to the slave MoonBot terminal via UDP. This is done to protect against false positives in the slave MoonBot terminal.


* A detailed explanation of why, when running the same historical trade data twice, the profit figures and even the number of trades using the same strategy may differ:


Unlike classic candlestick algorithms, where all figures are always clearly defined, and you can calculate "2+2=4" ten times and always get always get the same result "4" - in scalping, the figures are random!


The reasons for this randomness are explained below using the example of two MoonBot terminals that trade one pair simultaneously with the same settings from two different dedicated servers (VDS):


1) Lag trades. One terminal received trades 10 ms later than the other and placed its order 10 ms later, and then the situation developed according to a completely different scenario: the first terminal bought and sold at a profit, while the second terminal bought later, did NOT sell at the same place, and closed the deal at a stop loss. The more active the market, the more pronounced this factor is. The most striking example is the "MoonStrike" strategy, where in the same situation one terminal manages to buy, while the other does not.

The backtest runs in EMULATION mode and has a built-in random delay factor to emulate this situation.


2) The recalculation of any parameters does not occur continuously due to discreteness. That is, the first terminal calculated something, and the second time it will calculate the new market state after a time T1. The second terminal performs the same calculation at a slightly different time T2, and even a 1 ms difference will result in a new trade being included in the calculation, and the calculation result for the second terminal will be slightly different. Other calculated figures will lead to different order parameters or no detection on the second terminal.

The discreteness factor is also present in the backtest, since the moment of pressing the "Start" button is not synchronised with the market recalculation cycles.


3) Similar things happen with Sell orders if you use certain Sell order management algorithms, for example: PriceDown (decreasing the Sell order over time), SellLevel (adjusting the Sell order to the previous price maximum), SellShot (following the Sell order within specified value ranges), SellSpread (adjusting the Sell order to the price spread) and even StopLoss. The operation of rearranging the Sell order is not instantaneous. Different moments of rearranging a sell order can lead to different final closing prices. The backtest emulates the time of rearranging an order: a random delay of 10-20 ms, as on a real exchange.