Trade expert " agent"

Nowadays, there are many ways to determine the tastes and preferences of a person even before a heart-to-heart conversation with him. You can tell about it by his clothes, manner of behavior in society and even the ring tone of a cell phone.

A chance to fantasize about the preferences of a person we have never seen is presented today. No fragments of clothes or the smell of deodorant will be used for this purpose. It turns out to be a little simpler and, at the same time, more exotic. All we have is a pseudonym on the forum (renoshnik), a first name with a surname (Yuri Voloshin) and the name of the expert - Agent_Fx_v07.

It is difficult to judge the coincidence of the coincidence of the title and the version number, but the associative series is as follows: Agent 007, James Bond. Maybe Yuri is really a fan of Bondiana, maybe just spy novels, or maybe the title had a completely different meaning... There is a lot of room for imagination.

In spite of the post-New Year mood, which just disposes to idle thoughts, let's try to return to the original goal - to consider the essence of a set of directives and operators, which all together make up a trading robot "Agent. а".

Author's version

The results of the author's test were extended for the whole 2009 year and for greater clarity all deals were brought to a constant volume of 0.1. EURUSD currency pair and H1 timeframe (see Fig. 1):

A modest net profit of 1218 dollars and an equally modest maximum drawdown of 598 dollars are shown. This is already not bad. But if we extend the testing period to two years, including 2008, we get the following results (see Fig. 2):

In this case, the net profit fell to $1,003 and the drawdown rose to $1,562.

As always, we will try to correct the situation by understanding the principles of the Expert Advisor functioning and making necessary corrections to its logic. First of all, we need to find the signal part of the Expert Advisor, where the decision to open this or that deal is made directly. As it often happens, generation of the decision takes only a few lines:

If(cci[1]<5 && cci[2]<cci[3] && cci[1]cci[1] &&
Open[2]>Close[2] && Open[1]>Close[1] && Open[0]<Close[0] && Open[1]<Close[0]) pokypka();

If(cci[1]>-5 && cci[2]>cci[3] && cci[1]>cci[2] && cci[0]<cci[1] &&
Open[2]<Close[2] && Open[1]Close[0] && Open[1]>Close[0]) prodaza();

Logic of the Advisor's work

The graphical equivalent of the lines presented can be seen in Figure 3:

When the CCI indicator line is above 5.0 and forms a peak, with the previous two bars being bullish and the current bar being bearish, a short position is opened.

If the CCI line is below -5.0 and forms a trough, with the previous two bars being bearish and the current bar being bullish, a long position is opened.

To the above descriptions should be added two nuances.

First is that the signal of opening a deal does not mean a momentary entry into the market. It is carried out only by a pending order, and a stop order, which is set at a distance from the current price, equal to the value of the input parameter of the DistSet Expert Advisor. By default, this value is 10 points. Therefore, we note at once that the probability of the order being captured by the price is quite high and we can say that we actually lose 10 points. In other words, we either gain less profit in case of a positive outcome, or increase the loss in case the stop is reached.

The second nuance is to use the values of an unformed bar, i.e. the zero bar. The point is that the Expert Advisor tries to catch the last tick on the candle. That is, the indicator readings and candlestick characteristics can already be trusted on 99%. It is quite another thing to catch the last tick of a candle in reality - it is a matter of luck. That is why some part of deals shown by the tester will not be executed when working online. It is not quite clear why the author wants to do this expert. It is much easier to open a trade at the opening of the next candle. This principle will be implemented in the edit-version.

Making adjustments

So let's smoothly move on to the strategy fixes. First, of course, we will fix the time of setting pending orders BuyStop and SellStop from the last moments of the current bar to the first tick of the next bar.

Bottom line we get the eighth version of the Expert Advisor, the results of which, when tested on the quotes of the last two years (2008-2009), are as follows (see Fig. 4-7):

The view of the balance curve is very similar to the one shown in Figure 2. That is, the very basis of the strategy has not suffered. But the numerical indicators have improved. Net profit increased to 2742 dollars, while the maximum drawdown remained at the same level - 1524 dollars.

If we make a comparative analysis of statistical data on the results of the original and current tests, it becomes clear that it was due to the change of the method of opening a deal from stop to limit that the additional profit was obtained.

It is confirmed by the fact that the part of profitable deals in both cases is approximately the same - 74% and 81%. But the average profitable deal in the first case made 27 dollars, while in the second case its value increased almost twice - up to 51 dollars.

The USDCHF currency pair has nothing to boast about. Perhaps, more fine-tuning of parameters is required here trailing stop or even the distance between the opening price of the pending order and the current market price. The parameters that were applied to the EURUSD pair are clearly not suitable for the franc - net profit of -1061 dollars.

Конечное значение баланса после проведения теста на GBPUSD оказалось положительным. Показана чистая прибыль 941 доллар, но вот максимальная просадка достигла огромного значения — 1716 долларов. В данном случае итог совпадает с франком – требуется персональный подбор параметров.

As you can see on the chart, there are very few optimistic zones. Mostly there are prolonged periods of losing trades. Although the balance curve is more stable than the balance curve on USDCHF. Therefore, the conclusion will be the same as it was on the franc.

Agent Optimization

Well, since we have come to the conclusion that on currency pairs where an acceptable result was not achieved, it is necessary to select parameters, then let's move directly to the optimization of the Expert Advisor. We will not go through the process in detail, we will only give the final parameters and results.

So, the optimization was performed on three input parameters of the Expert Advisor:
DistSet — расстояние между текущей ценой и отложенным ордером;
MinProfit — уровень прибыли в пунктах, при достижении которого один раз за свечу в положительной зоне перемещался стоп;
Tr_Stop — дистанция, на которую перемещается стоп от текущей цены.

The first results are for USDJPY (see Fig. 8). The parameters were taken as follows: DistSet = 14, MinProfit = 15, Tr_Stop = 50.

Net profit is already 2259 dollars, and the maximum drawdown is only 783 dollars. These figures exceed the result achieved on EURUSD and they can be recognized as the best so far, as the recovery factor reached 2.89.

Next we present the results for GBPUSD (see Fig. 9). The most optimal parameters turned out to be the following: DistSet = 24, MinProfit = 40, Tr_Stop = 45.

Net profit of $3575 with a maximum drawdown of $1437, which gives a recovery factor again greater than two - 2.49. In addition, the view of the balance curve has changed towards stability.

The remaining currency pair is USDCHF (see Fig. 10). Its optimal parameters are: DistSet = 24, MinProfit = 25, Tr_Stop = 10.

Unfortunately, even optimizing the parameters did not give decent results. Nevertheless, the net profit is positive - 1212 dollars, and the maximum drawdown is pretty tolerable at $796. But here is the recovery factor did not even reach two - 1.52.

Conclusion

The analysis and subsequent point correction of the strategy showed how dramatically the results can change from the slightest interference in the logic of the program. And the fact that the changes are rather insignificant only confirms the expression: "Luck is always near, you just need to reach out to it".

To download

Test.zip - detailed results of testing of advisors;
Agent_Fx_v07.mq4 - original version of the advisor;
Agent_Fx_v08_edit.mq4 - A revised, corrected and expanded version of the strategy.

Leave a Reply

Back to top button