Showing posts with label The creation of trading strategy. Show all posts
Showing posts with label The creation of trading strategy. Show all posts

Thursday, 23 February 2012

AUTOMATED TRADING

|2 comments


We have noted in Chapter IV the difficulties of the work of each trader. The presence of this difficulties gives rise to different disputes around the question who is more successful in trading: a human being or a trading robot.
A person who carries on trading at the market depends on emotions and mood swings, level of health, tiredness, the influence of external information (news, gossips, analytical materials) etc. This list is endless. The exceed self-confidence is another factor that has to be taken into consideration. It appears among the beginning traders after their first success, and can influence badly on the further results. The positive side of all this is a human intellect and experience, and also creative (in good sense) methods of work.
A computer of nowadays has no creativity, and AI achievements (achievements in development of artificial intelligence) in general are not that good in comparison to a human mind. Nevertheless a computer has the whole number of advantages: it can work stably very long time, it does not need to take a rest, or to sleep, he does not make decisions that depend on emotions. In its actions it follows strictly and implicit the algorithm, that in its turn, realizes that or this model of the situation at the market.
A trading robot (Mechanic trading system (MTS) or EA is a computer software that has special program language or the language of special purpose (It can be MQL4, MQL5, EasyLanguage, Qpile and other languages included in the relative trade platforms as well as such languages like ะก+ or +C#, Delphi, VisualBasic etc). In case if the language is a part of trade platform (installed in trade terminal), then it can use directly the opportunities of the terminal for trading operations. To program using main languages for that or this platform API functions are needed that are provided by some brokers companies. LiteForex propose to its client either MetaTrader4 or MetaTrader5, that has installed MQL4 and MQL5 languages respectively. It allows to an IT-manager to get access directly to all possibilities of trade terminal and make different trade operations without any additional means (so-called "bridges", "connectors" etc).
The main feature of a trading robot is that there is a possibility to test the strategy that is presented as a program using historic data (i.e. to model its behavior as if it worked in the past and to estimate the results of this work). Undoubtedly it has to be remembered that the strategy profitability in the past is a guarantee of the profitability in the future. However due to testing it is possible to a certain extent to estimate the strategy profitability and its risks. From this point of view it can be noted that a trading robot does not "guess" the market, but uses statistic advantages of his strategy. The modeling of the work of the strategy in the past can has mistakes and should not be regarded as absolutely accurate.
In case of the positive results of the strategy, that satisfy a trader, a trading robot can get the possibility to make an operation at the real market. LiteForex company provides to all client VPS service (virtually honest server), that allows to set a trading robot to remote machine. You will not need to leave your PC switched on: LiteForex server will work for it. 
With such instruments (VPS+EA) you can fully organize automated and authorized work of your own strategy at the Forex market. As it was said abode, the server can be provided by LiteForex company (along with it you can use the services of any other companies, that provide with such a server or use your own PC, however in the last case it has to be switched on with stable Internet access and uninterrupted power supply). Thus, the question of the place of installation of a trading robot we consider as a technical matter. And now let us see the process of creation of a trading robo

IDEA

|0 comments


First of all you need a trading idea. Trading idea is a certain method of work at Forex, that, as the author supposes, can bring profit. There are dozens of good trading ideas on the Internet. Some of them are formalized and described very good, the others are shown in general terms. The ideas of "scalping", "arbitrage", "trading in the channel", for example, are wide-spread and make together the whole class, each of which has many separate strategies. Each of these classes is a generalized approach to the gain of profit at the financial markets, that is general for all or most of strategies. that make part of it. That is why this class ("scalping", for example) cannot be regarded as a trading idea.
One of the classic example of a good trading idea is "Turtles". Using this example we will review all the stages of building of mechanic trading system (MTS), excluding only a concrete program of realization, as it is a topic for another discussion, and we cannot include it in our course. 
It is no coincidence that we have chosen exactly this example. The case is that in accordance to the most wide-spread version of the history of origins of this strategy, it was created to solve the arguments around the question if a trader needs a special talent, a God's gift or "sixth feeling" ("vision of the market"), to understand the art of trading or it is enough just to obtain a certain set of strict rules and follow them.
The sense is if the idea to gain maximal profit of long-term trends, when they appear. (For note: it is considered that about 35% of time any market is in state of ascendant or descendant trend, and 65% - is in flat). The flat period for "Turtles" strategy is an unprofitable one, however when it forms the trend then all the loss accumulated during flat-period is crossed by one-two transactions and profit appears. The business here is that the strategy "Turtles" supposed strict limit of loss positions at the stage when the loss could not become too big. Thus the unprofitable transactions were small. At the same time if a trend starts to form, then Turtles allows the profit to grow without closing of profitable position, when the size of profit is too small. Thus it is possible to say that Turtles realizes one of basic rules of trading: "Limit the losses and give rise to the profit!"
Before we will start another chapter, it has to be noted, that primarily Turtles was developed for the trading of futures contracts at the exchange market. We will consider it at the Forex exchange market. We will make some simplifications to help to a beginner to understand the most important information without insignificant details that may be considered independent

FORMALIZATION

|0 comments


The building of mechanic trading system requires more than just one idea. It may be enough for introduction of so-called "intuitive trading". But it requires the gift and, of course, well-developed intuition. It should not be denied that there are people with such abilities. But we do not take this variant into consideration. We will describe here the things that are connected with building of mechanic trading system, that will follow strictly to certain rules.
The rules of trading system should be simple and understandable: available for formalization and exposition in one programming language. The definition of complex of such rules will be the formalization of trading system. All together these rules should give strict, accurate and informational answers to the following questions:
  • What financial instrument should be chosen for trading (the building of a backlog, diversification)?
  • What volume should have each transaction (the size of the position)?
  • What conditions are required to open the positions (the conditions of enter)?
  • What level is needed to leave the loss position (stop-loss)?
  • What level is required to leave the profit position (take-profit)?
  • What methods should be used to open and close the positions (by pending order or the market)?
The systems that have answers to these questions are considered to be "full" systems.  
Let us formalize the Turtle trading strategy using following rules (it is noted, that the original description of Turtle trading system is a little bit more difficult and can get a beginner confuse):
  • There are seven currency pairs should be used, that make part of "Majors" group, including EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD, NZDUSD, USDCAD.
  • Each transaction margin should be equal to 1% of deposit. Rounding to 0.01 lot.
  • The opening of the position should be made with the exceeding (at least to one point) of the maximum level (buying) ir minimum level (selling) within last 20 hours.
  • The closing of position with loss should be made after reaching the loss equal to 2% from the current deposit.
  • The closing of the profitable position should be made after exceeding the size of floating profit by 2% - after reaching 10-hours minimum (for the buying position) or 10-hours maximum (for selling position). 
  • The opening and the closing of positions should be made by pending orders: buying - buystop, selling - sellstop, quiting - stoploss.
In our small (very simplified) complex of rules we do not regard the moments, that are connected with "resupply" (increase of volume of the position in case of movement of the market in desirable direction), and also some other moment, that we consider to be insignificant ones. Also the primary Turtle system was meant for a longer time interval.
Let us leave comments for each rule. 
The usage of several currency pairs will permit to reach two goals. Firstly, it is a diversification (distribution of deposit between several instruments with the goal to minimize risks and optimize profit). Secondly it increases chances to "catch" the trend: meanwhile one instruments will fluctuate in the flat, the other may make part of the trend.
Singling out the separate small volume for the transaction allows to exclude practical possibility to lose the whole deposit (it will need a big quantity of transactions one after the other). It is necessary to open a transaction with 1000 dollar deposit using the volume equal to 0.01 of lot (marginal deposit for 1:100 leverage in this case $10, i.e. 1% of deposit). 
Speaking about the level breaking, there are different rules in different systems, that allow to identify the break. The case is that it is useful to decrease the quantity of system reactions for so-called "false breaks" - when the price breaks the channel position for some time, and then returns. However it will make the system more difficult. In our case we will not add additional rules of filtration of false breaks, we will count that any increase of price limit of the channel for at least 1 point is a break and it should initiate a transaction.
The price of one standard point in case if the volume of transaction will make 0.01 of lot, will be equal to $0.1 (10 cents). It means that 200 point loss ($20 or 2% of deposit) requires the closing of transaction using stop-loss.
When the price starts moving in favorable direction (for buying transaction - it is the growth, and for selling transaction it is a decrease), then we start gradually to move stop-loss, setting it every our at corresponding 10-hours minimum (for buying transaction) or 10-hours maximum ( for selling transaction). 
The usage of pending orders for opening and closing of the position will increase the accuracy of rule following, avoiding losses with the help of quoting.

TESTING

|3 comments


The rules described above can be exposed in any programming language including MQL4. We will not take into consideration the refinements of programming in this language. Those who desire can find on the Internet not only ready guides, that help to realize Turtle algorithm, but also step-by-step manuals for the writing of such strategies. Let us discuss some other things.
In case if that or this algorithm is exposed in the form of programming language, the possibility appears to define its strong and weak sides using historic data. MT4 also gives such a possibility. It has to be noted that modeling of trading system behavior may have some mistakes and should not be considered as absolutely accurate.
To make the testing to give important statistic data we should take into consideration the following recommendations:
  • Within testing available time the system should make big enough quantity of transactions. If n accordance to the system the average transaction has 10-hours-period, that the strategy has to be tested at the 1000-hours interval (to receive about 100 transactions). In other words it can be exposed as a demand of representation of statistic output.
  • As the results of testing may depend on the moment of beginning of testing period, it is reasonable to test the system, changing the point of start of the test.
As the result of tests of Adviser a trader gets statement and graphic of changes of account features like balance and equity. The data analysis - it is a separate task, that, unfortunately, cannot be described in this course. It should be noted that it is necessary to analyze attentively and estimate such important test results as correlation of profitable and unprofitable transactions (in accordance to the quantity and total volume of profit and losses), profit-factor, maximal drawdowndown in one transaction, maximal drawdowndown in continual series of unprofitable transactions, and also maximal profit in one transaction and maximal profit in continuous series of profitable transactions.
You should also pay attention to the even interchanging of unprofitable and profitable transactions. The results of analyses allow to make a conclusion about the most suitable strategy of money management for given trading strateg

SETTINGS (ADJUSTMENT)

|0 comments

SETTINGS (ADJUSTMENT)

In accordance to analysis results of the test a trader can make a decision about the changes of those or these features with the goal of optimization or maximization those or these features of trade strategy. In particular, you can try to maximize profit or find optimal correlation of profit and risk at the current level of risk.
The most important nuance in the question of trade strategy - is segmentation of all available massive of work of historic data into two general intervals: test and valid one. The size of valid interval should give representational statistical sampling. The size of test interval can be larger or the same (it is desirable for this size to be twice larger).
Picture 19. Test and valid interval
The deal is that any given historic period can choose those settings of the strategy that will make it more profitable. The strategy in process of such setting is "matched" to the given data. The effect of so called "resetting" is when the strategy with definite settings gives good profit at the test interval, but at the valid interval ("unknown" for the trade work) the profit goes down.
On the basis of Turtle strategy let us see what settings can we change in process of optimization:
1. "Sensitivity" of the system to appearance of new trends increases, of the entering follows the break of less important levels (for example, instead of 20-hours maximum or minimum you can use 10-hours one). This will lead to the situation when the system will enter the market more frequently, and it means, that it will make more transactions. n the one hand, it is a plus. However on the other hand this more "sensitive" system will react to the bigger quantity of false breaks, and thus, the quantity of unprofitable transactions with those of them that follows one another, will grow. If the "sensitivity" of signals become smaller, the system will catch more significant trends. However in this case the system will enter the market significantly rarely and most of the time, the funds will not work, and will just stand idle.
2. In the same way you can change the "sensitivity" of the system to the turns, decreasing the degree of importance of extremums that give signals to quit.
3. Changing the capital share that is given for each certain transaction, you can increase the efficiency of money usage (i.e. the capital percent that makes part of investments will increase). However you should take into consideration that this increase of some long series of losses can bring strategy to deposit loss.
In case if the change of those or these settings bring to the successful results of the work of system at the test interval, the system should be tested at the valid interval to make sure that there was no "resetting" to the concrete historic period. The system, the settings of which are chosen optimally will give approximately the same results during testing both at test and valid intervals.
Apart from this the similar settings should be done (choosing test and valid intervals from the whole available historic period) for several different currency pairs. Thus the system will work normally with forecasted results for the chosen currency pairs (In our example it is the group of "margins"). 
It is strongly unrecommended to fudge settings of the system to the valid interval. In cases when you see that the system changes its behavior sharply at the valid interval, you should make a conclusion about probable "resetting" of the system to test interval and make a step back. 
Among other mistakes it has to be noted the situation when very good results of system work are obtained only at concrete test interval. The market dynamics at this interval can be very suitable for your strategy. For example, for Turtle strategy it is a very long trend with insignificant drawdowns. Even if test period is very long, but within this period the market behavior was characterized as monotonous (for example, trend only or flat only), you should try another interval and estimate the given difference. You should not try to chose the optimal settings for each definite period: in future the market will make such a position to which the system will not be rea
free counters