A trading system based on indicator CCI

Script examples. A trading system based on indicator CCI

Wikipedia Commodity channel index

Commodity Index indicator is very simple in fact, though it has such a fancy name. Indicators in TSLab are based on C#. For those who have programming skills we provide API and indicator code samples at our Forum. CCI is available in TSLab as other indicators as well, but I would like to demonstrate a self-made one built according to wiki formulas. It is very easy to build new indicators by means of TSLab. CCI consists of Typical Price and Simple Moving Average. TSLab already has all to create CCI, but I showed in the indicator how to create Typical Price and Simple Moving Average. I urge you to study indicators. Making changes to indicators, you get a chance to create a better one.

Here is a customized CCI indicator. I applied adaptive moving average instead of simple moving average. And I applied exponential average instead of typical price. The chart in the middle shows the original CCI and the self-made one. As you may see, their values are identical, as CCI in TSLab is done as it is described in wiki.

The lowest chart shows the customized indicator. It has clearly seen divergences.

Though it is not so unstable as the original one, it seems to be more flat. Wiki offers 2 types of strategies, saying that there are different points of view on this indicator. To build these strategies, I am going to use my customized indicator instead of the original one. Some people think that in case with long positions we should buy, when CCI is higher than 100 and sell, when it is lower than 100. And for short positions – Sell when CCI is lower than -100 and close a short position, when CCI is higher than -100. For example, this strategy doesn’t seem to be profitable with bitcoin at all.

Other people recommend using zero value as a signal calling this strategy Zero CCI. It means - buy (open a long position or close a short position), when Commodity Index is higher than zero or sell (close a long position, open a short position), when CCI is below zero.

Let’s build a script which comprises both variants and resolve the dispute by means of optimization. If we think a bit we can see that there is one more strategy besides these two, this is to use average of CCI instead of signal lines. And we can at least combine all three strategies together. For example, we can enter a position at about zero point. And close long positions when CCI crosses its average, when the indicator is higher than 100 and lower than -100 for short positions. My customized indicator won’t do for this strategy because of divergences. The original one won’t do either as it is not stable and there can be many false signals. Try to create an indicator as flat as mine or even better but with fewer divergences.

Good luck to everyone!

This is just an example of trading strategy for TSLab learners.

CCI_wiki.tscript CCI_custom.tscript CCI_wiki_custom_simile.tscript CCI_100.tscript CCI_Zero.tscript

Download the file. Click Lab in TSLab main menu, then choose Script manager. Click the Load from file button.

Last updated