Note that all the values you set when backtesting the cBots won’t affect any of your accounts as they are not intended to deal with the real funds and are used for the demonstration purpose only.
cTrader Automate advanced backtesting functionality allows testing cBots’ performance within a certain time period under a specific set of conditions. One can define a testing time period, start a cBot, and watch the results for how a cBot instance would have performed.
To backtest a cBot, select a cBot instance that you would like to test and proceed to the Backtesting tab to the right.
Define a time period for the backtesting by using the drop-down calendars or typing in the dates, or by dragging the slider between them.
Use the cog icon to set the Backtesting Settings.
When done click the Play button to the upper right to start your backtesting.
cTrader Automate allows visually backtesting the cBots to track the cBot work in the real time with the possibility to regulate the backtesting speed.
Check the Visual Mode box under the Backtesting settings icon to enable the Visual Backtesting.
Set the Backtesting Settings and select the backtesting timeframe as described above in the Backtesting Settings section.
Set the speed of your cBot instance testing using the Speed slider or toggles to the right.
When done click the Play button to the upper right to start the backtesting in the Visual Mode.
The Backtesting will start with the options and speed you have set and you will be able to track it in real time using all the cTrader instruments including zooming, changing the chart type, adding the indicators and drawing the chart objects, etc.
Note that you can use the progress slider to move forward on the X-axis, during the backtesting process, but you can not move backwards.
Also, you can change the speed of the backtesting process by using the speed slider or the toggles to the upper right or pause backtesting to view the intermediate result or apply some changes to the chart (add indicators, draw objects etc.).
If you are using the Visual Mode for backtesting your cBot, then you can track your cBot instance testing performance in the real-time in the chart and in the progress bar. If the Visual Mode is off, then you will only see the testing results and the progress bar. In both cases, the backtesting may take some time to complete, depending on the timeframe, speed, and other settings you have set. You can estimate the progress and time remaining by looking at the Loading message displayed when loading data for the backtesting, or at the Visual Mode progress bar if the Visual Mode is on.
Once completed, the full details of the testing results will be displayed in the tabs below, including the positions, orders, trade statistics, historical data, events, as well as the cBot log.
Positions
All the opened positions are displayed in the Positions tab. It includes all the standard cTrader Positions information like traded instrument, position volume, direction, commissions, Net profit, etc.
Orders
The complete list of all the cBot orders and order options are displayed in the Orders tab.
Equity Chart
The Equity Chart tab shows the changes in the Trading Account equity in relation to account balance over the backtesting time period. Click anywhere on the Equity chart to automatically track the respective time period in the backtesting chart above.
Trade Statistics
All the cBot backtesting trades information is displayed in the Trades Statistics tab. Here you can find the following Trades statistics with the division to All Trades, Long Trades, and Short Trades:
History
The History tab lists all the Closing Deals of the cBot instance backtesting performance including all the details like entry and close time, trading symbols, their volume, directions, entry and close price, and profit.
Events
All the created and closed positions during the cBot instance testing run are displayed in the Events tab.
Log
The Log tab contains the list of all the cBot instance backtesting information. You can search the required events by typing to the search box to the upper left or use the filter to display only cBot testing statistics info or trading events.
cTrader Automate advanced Optimization functionality allows determining and applying the optimal set of parameters for a cBot based on the backtesting results. The Optimization runs multiple backtest procedures and compares their performance.
To optimize a cBot select your cBot instance and proceed to the Optimization tab to the right.
Define the backtesting time period for the optimization by using the drop-down calendars or by dragging the slider.
Optimization Parameters
Click the Parameters button for setting the parameters to be optimized for your cBot.
Specify the required values for the parameter to be used during the optimization. Alternatively, uncheck the parameters that you are not going to optimize.
Optimization Criteria
Click the Criteria button for setting the standard or custom Optimization Criteria.
The standard Optimization Criteria group provides an ability to minimize or maximize the required trading factors, to be used during the optimization. Fitness value will be calculated for each pass based on the set of selected criteria. The higher fitness value, the better.
Click Add Criteria to add more criteria, or click a cross next to a criteria to remove it.
If the Custom criteria are selected, you need to override GetFitness method in your cBot and provide a fitness value based on GetFitnessArgs. The higher fitness value, the better.
Example 1:
protected override double GetFitness(GetFitnessArgs args)
{
//maximize count of winning trades and minimize count of losing trades
return args.WinningTrades / args.LosingTrades;
}
Example 2:
protected override double GetFitness(GetFitnessArgs args)
{
//count of winning trades is more important than count of losing trades
return Math.Pow(args.WinningTrades, 2) / args.LosingTrades;
}
Method
Click the Method button (GA or #, depending on which method is selected) to select the Optimization Method. Two options are available:
Resources
Click the Resources button to set the CPU consumption for the backtesting optimization. Move the slider to set the CPU usage percentage. The more resources you allocate, the faster the optimization will be performed.
Note that the CPU resources can be adjusted during the optimization.
Note that the Backtesting Settings described above are also applied to the cBot Backtesting Optimization.
Start the Optimization
When done click the Play button to the upper right to start the Optimization. The Optimization process may take some time depending on the optimization settings and the complexity of a cBot. You can view the number of passes, the elapsed time and the remaining time estimate to the top of the Optimization tab.
The optimization process runs backtesting multiple times. Once backtesting for a specific set of parameters passed, the new row is added to the Passes grid.
The Optimization Results
When the Optimization is successfully done, the detailed results of all the optimization sessions performed are displayed in the Passes grid below. Note that the Pass grid is configurable. You can drag the columns to change their location, or enable or disable the required columns by right-clicking and checking the columns you need.
The Passes grid contains the following columns:
Select a pass to view the detailed information on it to the bottom of the optimization window. The following parameters are displayed:
Note that if you enable the Autoselect the best pass option before you start optimization, then the best fitting pass will be automatically highlighted in the optimization results.