Click here to Login

Optimize a trading strategy using the Sharpe ratio

Updated on 2010-07-06

We all agree that a strategy that returns 50% is better than the one that returns only 30%. But what if the volatility of the daily returns of the first strategy is 50% and the maximum drawdown is 60%, while in the second strategy the volatility is only 30% and the maximum drawdown is 20%.
Like most traders, I will certainly go with the second strategy despite the fact that it provides a lower return. Decreasing risk should be our top priority in the trading and investment world.

It is easier to compare different strategies using a single metric. We can for example us the Sharpe ratio which is very popular measure of return per unit of risk. It will instantly tell us which is the better strategy. In a single measure it includes both return and risk information about a strategy.

Usually when traders perform trading strategy's optimizations using an advanced algorithm such as the genetic algorithm, they put too much emphasizes on strategies' return. They usually set the strategy's return as the fitness formula of the genetic algorithm.

In genetic algorithms, the fitness is a value used as a rank measure. It let the program knows which trading strategy to choose when creating new generations.
As we said, strategy's return is often used to define the fitness of a genetic algorithm. This is good, but we can get much better results if we change the fitness and include a measure that incorporate both return and risk, such as the Sharpe Ratio.

In the Optimizer tool of QuantShare, you can select what to optimize (Trading rules, trading system, neural network model, ranking system), which algorithm to use (Genetic Algorithm or PBIL) and you can also create your own fitness function.

Select "AI" -> "Optimizer" then click on "Create". In the Optimizer form, select "Trading System" then click on "Next" twice. Below, there is a text editor where you can type your fitness formula. As with all scripts in this trading software, you can click on CTRL + SPACE to display the list of available variables.

By default, the fitness formula is set to:
Fitness = AnnualReturn;

This means that the annual return is used to rank strategies.
We can use instead the Sharpe Ratio as a rank measure simply by typing:
Fitness = SharpeRatio;

Sharpe Ratio

no comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

Create Graphs using the Grid Tool
Posted 1298 days ago

Profile Graphs
Posted 1403 days ago

Previous Posts

Correlation of market indicators
Posted 5157 days ago

Backtesting Process
Posted 5171 days ago

Trading software new features
Posted 5177 days ago

Optimization of a trading system
Posted 5192 days ago

More Posts


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.