Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.) [ ru ]
Introduction
In my previous articles from this cycle (1, 2, 3, 4) I described simplest trading systems, the distinctive of which was working on only one frame. As a result, such a trading system has absolutely no reaction to the change of market trends in a more global time scale. This may result in losses in conditions of a changed market, such changes are not detected in a system of that kind. Actually, in live trading systems based on data obtained from a chart of only one timeframe can hardly be used. Usually at least two timeframes are used for a normal operation. A current trend is usually identified on a chart of a higher timeframe, while the point of market entering in the direction of this trend is calculated on a chart of a smaller timeframe. In my opinion, examples of simplest trading strategies described in previous articles are enough for a reader to learn designing such systems. So now let's discuss methods to improve such trading systems on the basis of the above described reasoning.
Trading System using Two Timeframes
From the point of view of logics, there is no difference, on the basis of what trading system described in previous articles we will build a more complicated system. As for their initial essence, each simplest trading system can be presented in the following form:
For long positions:
For short positions:
In our trading system using two timeframes, these conditions for market entering will be defined on the basis of indicators calculated on a smaller timeframe. Trend direction will be identified on a higher timeframe. So, the algorithm containing these conditions will look like this:
For long positions:
For short positions:
In this case the Trend variable defines only the direction of a current trend on a higher timeframe and the additional condition for market entering limits trading actions of an Expert Advisor only to the direction of this global trend. From the point of view of program code, it makes no difference using what algorithm the current trend will be detected on a higher timeframe. So it is up to an EA writer to decide what algorithms to use both for calculating a market entering point on a smaller timeframe and detecting the current trend on a higher timeframe. Let's analyze the earlier described algorithm with the OsMA oscillator represented by the EA Exp_5.mq4, to define the current trend let's use the moving J2JMA.mq4. In such a case the condition of trade defining will be very simple: