Steps to create a profitable trading strategy

In this very short article, I will describe the steps that should be taken, in my opinion, to make trading strategy profitable

Slawomir Lisowski
3 min readJun 4, 2023
Steps to create a profitable trading strategy

What trading strategy really is. In my opinion, trading strategy is your own trading rules, that let you achieve stable and certain, as much as possible, rate of return. Strategy let you avoid walk in the dark and make decisions based on emotions, what is the worst situation in investing money. Of course, not always, your strategy will be profitable, but this post will bring you closer to that how to prepare a strategy to avoid unnecessary losses.

Choose your strategy

The first step is choose your trading strategy and you ask immediately how do it. Strategy should based on some indicators or other assumptions related to prices or volume . Of course we are talking about technical analysis indicators because with prices and volume of the instrument, there is possiblity to constantly tracking, the value of the indicators.

There is many technical analysis indicators, but of course you can create your own indicator using price or volume or combination of them. If you see the price chart and your indicator, and some relationship between them looks well, maybe this is strategy for you. Very important are rules that we will apply to the price, volume and indicator, in other words, what must happen with them, in order to make a decision to buy or sell instrument . But before implemet it in real trading, don’t forget to check if it will be profitable.

Collect data

Before we start testing trading strategy, we need data. In previous post you can find guide how to do it with XTB broker How to collect data with XTB API ? .

Backtesting

Backtesting is analysis of your strategy, based on historical prices of given isntrument. Analysis, it means, get metrics that let you make assumption, that strategy you have chosen will be profitable in the future. As you see, we have used word assumption, because there is no certainty that the strategy profitable in the past, will be profitable in the future. Conditions that have occured in the past on the market, not always are the same today, so we should test our strategy carefully.

Backtesting should take into account transaction fees — spread. When it comes to metrics there is many to choose from, depending on that what do you want to achieve: maximum profit, minimum risk, or for example optimal level of the leverage.

Optimization

This step is sometimes overlooked in preparing trading strategy. But nothing stands in the way of choosing this set of e.g. frequency and period for technical idnicator, that allows us to maximize profit. In times, when we have access to almost unlimited computing power, few lines of code let us test all possible combinations for certain ranges (frequency and period for technical indicator) in a few seconds, a few minutes at most. Of course there is still no guarantee, that the strategy will work well in the future.

Forward testing of trading strategy

In the section about backtesting, we said that drawback of it, is using historical data and choosing the trading strategy, that may not be as profitable in the future. So solution, that will allow us to overcome this problem, is split dataset on backtest sample and forward test sample. Let’s assume, that we work with data from backtest sample and strategy looks promising. It means that strategy works well with the data seen before. Forward test sample let us simulate future prices and market conditions, as well as, test our strategy on it. If the forward tests confirm our hypothesis of the effectiveness of the trading strategy, it’s time to incorporate the strategy into real trading.

Each of the described steps is part of larger process, that can be treated as some kind of algorithm. Now it’s time to look at practical side, which reveals how convert particular step into Python code and use it in this process.

More you can find on my github .

This article is not investment advice. The information contained on this website and the resources available for download through this website are for educational and informational purposes only.

--

--

Slawomir Lisowski

I'm passionate of data science and machine learning, especially in the field of finance and trading. Investing is risky. Invest responsibly