CANCEL

or via PTMC account
or via PTMC account
or via PTMC account
or via PTMC account
or via PTMC account
or via PTMC account

# Optimization of the trading algorithm : Target functions and setup

In the last article we considered the features of the two optimization algorithms which are available in the Protrader terminal, namely: genetic algorithm and particle swarm optimization. Also we examined in detail the configuration of each algorithm and noted the impact of the settings on the optimization process. Let’s move to such an important component of the optimization process as target function. Recall that the task of the optimization algorithm is to find the maximum or minimum (extremum) of some target function. Different statistical indicators of trading system can act as the same target function. For example, the profitability or the expectation value of the trade. Using the Protrader terminal, a trader can choose from the 12 standard target functions; the possibility to use multiple target functions with specifying weight coefficients for each of them is also implemented. To select the target function, after setting optimization parameters and algorithm of testing, just go to AlgoStudio - > Optimization window, and check the needed target functions and also determine their weight in the calculation of the resultant target function.

In this example, the resultant target function equally depends on ‘Profit factor’ and on ‘Sharpe ratio’, as their weights are equal.

Let’s decipher each of the available target functions:

1. Annualized gain – is the value of earned profit on an annualized basis.

2. Average profit – is the average profit on trades. Example: trading system for the reporting period received 1 profitable trade (100 arbitrary units) and 1 losing trade (50 arbitrary units).

Average profit = (100+(-50))/ 2= 25.

3. Gross profit – is the total profit earned for the reporting period excluding commissions.

4. Max drawdown – is the maximal drawdown or monetary loss for the period of trade. Example: initial deposit = 100 arbitrary units, trading system increased the deposit up to 1100, and then there was a series of losing trades, as a result, only 800 arbitrary units remained on the account. The trading system has returned the account balance on the level of 1100 and above at the end of the reporting period. In this example, Max drawdown = 1100 – 800 = 300 arbitrary units. It should be noted that this indicator is the most common in risk assessment.

5. Payoff ratio – is the payout coefficient that is calculated as a ratio of the average percentage of the profit on the trade by the average percentage of the loss on the trade.

6. Profit – the profit earned by trading strategy taking into account the commission.

7. Profit factor – is the factor of the system profitability. Is the ratio of profit to losses. Example: trading system for the reporting period produced 10 profitable trades which brought 1000 arbitrary units of profit, and 3 losing trades which brought 600 arbitrary units of loss.

Profit factor = 1000/ 600 = 1.66.

8. Recovery ratio – is the recovery factor. This indicator displays how quickly investigated system is recovering from the losses and calculated as the ratio of net profit to maximal monetary loss.

Recovery ratio = Net profit/ Max drawdown.

Usually, the system is considered to be stable when Recovery ratio > 3.

Example: net profit from the work of trading system was 300 arbitrary units at the end of the reporting period, and the maximal monetary loss was 90.

Recovery ratio = 300 / 90 = 3.3.

9. Relative drawdown – is the drawdown or the monetary loss for the period of trade which is defined as the ratio of the maximal drawdown to the initial balance. Usually is displayed in percent.

Example: initial balance = 100 arbitrary units. The maximal drawdown for the reporting period was 300.

Relative drawdown = (300 / 1000) * 100 = 30%.

10. Sharpe ratio – is the Sharpe coefficient, the common measure of trading system efficiency. It is calculated as the ratio of the average profitable trade that decreased by the risk-free rate to the standard profitability deviation. The smaller the variance of profitability, the more stable the system. Example: average profitable trade = 100, let’s assume the risk-free rate to be 0 (in some cases it is taken equal to the rate of bank deposits or interest rate on government bonds), standard profitability deviation was 50.

Sharpe ratio = (100 – 0)/ 50 = 2.

11. Trades – is the number of the trades which was made by the trading system for the reporting period. For reliable statistical analysis of the system is necessary that the trades’ selection was statistically representative.

12. Win/Loss ratio – is a ratio of profitable trades to the losing trades. This indicator reveals the features of the system; its small value indicates that in the system there is a large amount of losses and a small amount of profit. Conversely, a large value of this indicator shows the high amount of profitable trades and small amount of losses.

Since a set of statistical parameters characterizes the trading system then the selection of the trading system optimal settings should be produced according to several criteria (target functions). For example, a trader can choose the best option of the trading strategy settings not only by the maximal earned profit, but at the same time by the minimal drawdown, as well as by the maximal recovery factor. A trader can define those statistic system indicators that are the most important to him. At the same time it is possible to specify the weighting coefficient for each of the selected target functions which will reflect the importance of any of the target functions when selecting the best optimization results.

In general view, the resultant target function has the form:

F(T)=T1*k1/100+…+Tn*kn/100

where, T1,…,Tn – are the selected target functions;

k1,…,kn – are the significance weighting coefficients of the separate target function.

Thus, after choosing the resultant target function which corresponds to the set goals, we can achieve the most efficient usage of optimization algorithms.

What to do if the assigned optimization task has a large number of optimized parameters, and the result should correspond to specific, pre-set conditions? For example, a trader interested in optimal settings of the trading strategy with the number of trades not less than 100 for the selected reporting period. Or a system with an average profitable trade not less than 50 points is needed for the diversification of the trading systems portfolio. The ability to set the optimization limits is provided for solving the problems of boundary conditions (limits) in the Protrader platform optimizer. Limits allow receiving mostly only those solutions that are of interest to the trader. To set the limits, go to AlgoStudio - > Optimization - > Optimization limits and click the ‘Add limits’ button.

We can select the criterion of the limit in the drop-down list. We should choose a logical operator and max limit value in the received row.

In the current example the optimization limit, in the preferred choice, consists of those trading system settings under which for the reporting period more than or equal to 50 trades will be produced , however, it is possible to obtain the solutions at which the number of trades will be less than 50.

We can state that the optimization process of the trading strategy in the Protrader is flexible enough, and can be successfully used by traders to achieve optimal results in a wide range of possible tasks.

Have not tried PTMC yet? There is no better way to boost knowledge than to use it! Start trading with PTMC now!

Discussion
No comments yet. Be the first. PTMC is a professional trading platform that combines all the best charting and analytical tools to trade on different financial markets. It is developed by PFSOFT UK LTD, a global provider of trading technology for banks & brokers
PFSOFT UK LTD
71-75, Shelton Street,
Covent Garden,
London, WC2H9SQ,
United Kingdom
Support & Development
PFSOFT Ukraine
Office #701
Mechnikova Street, 10B
49000, Dnipro, Ukraine