TRADESIGNAL HOW TO 14.
More Than Bar Charts.
BACKTEST ALGORITHMIC STRATEGIES.
There is more to charting than displaying a simple open-high-low-close bar or candlestick chart. The same is true for algorithmic trading. See this article on how to backtest algorithmic strategies on other than bar and candlestick charts.
Chart types in Tradesignal
Beside traditional candle and bar charts, Tradesignal offers Renko, Kagi, Point&Figure, Three-line break and Heikin Ashi charts. The common thing with these more advanced chart types is, that they all contain an algorithm to only display significant moves. They do not plot every days open, high, low, close data, but have got some rules on how to evaluate if the price of today is worth plotting.
As an example, Renko charts are based on a specific box size. Only if the market moves more than one box, a new box is drawn. Otherwise the chart stays unchanged. The specific idea behind this chart type is, that it tries to filter non-significant moves.
On the chart above the same slice of data is displayed as a 2% Renko chart and as a traditional candlestick chart. The Renko chart only shows a new brick, if the market has moved more than 2%. This filters insignificant data and helps in identifying the major moves.
Backtests on alternative charts
When back testing an algorithmic strategy you usually run into one significant hassle: as the chart does not display the “real” market data of the day, you can not use the prices seen on the chart to calculate your historic returns. Luckily Tradesignal knows about this problem and does all the needed calculations in the background. So if your strategy says “Buy if my chart crosses above its moving average” Tradesignal would loop through the historic open/high/low/close data which was used to calculate your advanced chart and return the right market price for the fill of your order. It would calculate the moving average based on the charts data, but the fill is done in the background using the real data. So be careful, there might be a difference between what you see on the chart and what happens in the background.
Verifying results
To make backtests on advanced chart types more intuitive, you can display the strategies fills on a normal candlestick/barchart. Therefore, you just have to add the same symbol you use for the advanced chart to your advanced chart. This will destroy the nice visuals of the advanced chart as it introduces a linear time scale. But this chart will also show the exact entry and exit points of your strategy at the time of action.
_
A code example for Renko charts
When coding a strategy with alternative chart types you have to be aware how this chart is built. To have a few examples let us start with a Renko chart.
As stated above a Renko chart is based on boxes. If your box size is e.g. 1 and the current box is a rising one and shows the price of 100, the closing price of the market has to be above 101 to show you the next box. One thing to be aware of is, that the Renko chart is only based on closing prices, but ignores the high and low prices of the actual data.
The chart above shows how the actual fill of the given strategy is outside the shown box. But you have to use this price to get a valid backtest, and not the price of the box. The next days opening price would have been the fill price of the order, the Renko chart was just use to generate the buy signal.
The next code example is a tricky one. The strategy waits for a rising box to close above a moving average. Then it tries to buy at the price of the average using a limit order.
To do the backtest, Tradesignal will first have to calculate the moving average based on the shown box prices. Then as soon as a box above the moving average is formed, it has to remember the price of the average and try to do an entry on the next bars. You can verify that it is done correctly by adding the same symbol the Renko chart is based on to the Renko chart, and see the actual fill prices.
The chart on the left shows how the fill would have been reported on the Renko chart. The chart in the middle shows the Renko average on a candlestick chart. Do so by dragging the average from the Renko chart on the scale of the candlestick chart. As you can see the red candles after the Renko brick with the signal, have not been big enough to generate a falling Renko. They all happened within the signal brick. For the backtest Tradesignal automatically looped through the real data, checked the Renko signal and then executed the order using the price of the Renko average when the market touched its level and filled the limit order.
You just have to be aware that the actual fill did not happen when the signal box was shown, but a few days later (but still within this box).
Using the optimizer
Alternative chart types can be used with the optimizer.
In the example above you could use the optimizer to find the optimal brick size for your strategy. To do so just select the appropriate variables in the optimizer menu.
On the picture above I am optimizing for the right brick size and the number of bricks used to show a reversal. This offers you an additional degree of freedom. Use it wisely.
Learn more about trading, backtesting and algo trading in our webinar series. Here is an overview of the next topics.