After the first implementations exposed in previous article, I am now to show more important aspect involved in automating a strategy and as promised, I will show the results I obtained after last arrangements.

Collecting data

When planning a strategy - will it be manual or automated - one key step is to collect all data obtained from tests, to quickly compare all results. So I invested some time to setup this simple table, using a program easily found for free on the web:

Using such a simple table, helps to understand if and how an arrangement really affects/or not a strategy, relatively to previous results. And it also helps me to save a lot of words!

Previous test

I finished last article showing the results obtained from the very first tests. After some days of study on strategy behavior, I came to the conclusion to reduce the stop loss and the take profit trying to stabilize the profitability by getting more profitable trades. Results were slightly better than previous, so I decided to take this as starting point. Here below you see the equity curve, obtained directly from Jforex visual tester:

The curve shows nothing new respectively to the raw data, but helps to visually understand where are main problems. In this case I would say problems are everywhere but again, still a great result considering it's the beginning.

Here on the left is the summary of all data obtained, showing a large 25% equity drawdown, profitability less than 50%, and a profit factor at 1.12 (not good).

Despite a good ending equity, showing a net 47,15% profit, a question comes to my mind: what if I turned-on the strategy in my real account in January? Would I have let it running until the end of February when returning about 50 losing trades out of 65 total position executed? And more: what if I executed it in the middle of february, getting a straight drawdown of more than 25%? Answer is simple: there is still a lot of work to be done!


I did a lot of tests trying to solve some of worst situations causing more than 3-4 losses in a row: basically using EMAs in a strategy, when price is trying to find a direction (also called "consolidation" pattern), we get a lot of false signals. In last article I shown this image:

The event repeats quite often and so deserved a particular attention. After many boring analysis and chart studies with different indicators, I came to the old CCI. Many times the indicator was showing strength while EMAs were showing continuation weakness, and opposite. A chart better represents what I mean:

As you can see, the CCI is continuosly above the 0 level, suggesting strength or at least a lose in downward momentum. A great opportunity, and actually the best obtained!

The code

Adding the CCI in the main code really required 3 lines (78-86-99):

In this way, it is required a positive CCI to open longs, and negative to open shorts. I also tried to get the previous candle value (shift 1) but results came better using 'current' candle (shift 0).

Test results

I obtained important changes both on equity curve and profitability.

During the tested period, starting equity never went in loss and the curve shows an overall ascending behavior, despite 2 drawdowns of 25%.

Profitability has slightly increased (+2,13%) and there is a total 90 positions (-46).

Adding the indicator helped to stabilize some trades, and filtering many losses but despite these improvement, still I have the same voice in my mind: what if strategy started in the middle of February?!


At this point I started to analyze deeper the whole situation: during February and March the cross tested (EUR/USD), experienced very bad moves in a tight range. Analyzing the whole behavior using the visual tester, I noticed that main losses are now caused by quick spikes up-down in price, ending to come back to the same point where the move started. I definetly decided some important arrangements in the code which will take me some days, but first of all I did some tests using different parameters.

New parameters

Sometimes, trying to contain a loss is already a way to get it. Since now positions are well filtered, I decided to try using different stop loss, take profits and other paramenters, because actually main losses are not caused by 'wrong' entries. Here below are the results.

The curve now is very soft and points upward. Still there are a couple of 18-20% drawdowns, but highest peak is quite far from the breakeven. Main improvements are seen in the table:

Important decrease of total positions, huge cut > 50% of losing trades returning a profitability of 50% (potentially 1 loss every 1 profitable trade). At this point the strategy starts to be more confortable, showing a profit factor 1.36 (profit/loss) which is nice if correlated to the profitability. On the other hand, we see the gross loss did not change and the average loss doubled.

The most important fact, is that the type of losses now is really different: when there is a loss, price was reversing direction, suggesting me that eventually a trailing stop, or a reversed position opening after the stop loss order triggers, will finally allow me to conquer higher profitability values and so to move on forward with more important tests.

Personally I would much prefer a strategy with similar results obtained in my last test, but with an overall stable behavior, instead of a super-profitable-but-volatile one which could hit heavy an account with 2-3 losses.


I decided this article serie, to show my personal approach on how to build, study, correct, and stabilize a strategy to be used in a real account, so taking the opportunity to share this simple one.

There are many aspects to care about, when considering to put a strategy on an account and I hope with my article serie, to give people a simple and 'quick' idea of what are main factors to watch: it's not about one or two single data, it's about understanding deeper and deeper what kind of losses the strategy returns, and how to manage with them to obtain better results.

Thank you for reading.

Translate to English Show original