Forex fuzzy in logic trading rules

Forex fuzzy in logic trading rules

Posted: Dedigal Date: 22.06.2017

Do you like the article? Share it with others - post a link to it! Use new possibilities of MetaTrader 5. A rapid development of technology has led to a stronger tendency of using automated trading systems on modern currency markets.

However, many traders still carry on using manual trading. Pros and cons of both trading approaches are very well-known: In fact, in this comparison, these are two extremes of the same essence. In my previous article I have given examples, where I tried to compensate disadvantages of the automated trade by applying fuzzy logic theory, for instance, by blurring overly strict strategy formalization, applied in a trading robot or an indicator.

In this article, an opportunity for improving the manual trading strategy will be considered. The use of modern technology, even at the manual trading regime where a final decision always rests with traders, brings more benefit than harm.

Forex fuzzy in logic trading rules and with it forex training seminars va

Many modern traders choose to take responsibility for entering and exiting positions, rather than rely on automated systems. They require to develop their own trading strategy that would take into account all possible outcomes of the market behavior.

Applying fuzzy logic in trading by means of MQL4 - MQL4 Articles

Afterwards, one would have to follow it strictly and resist any impulses that could be provoked by fear and greed. Therefore, first we need to come up with a trading strategy. Let me describe you three stages of how we are going to build it. At the first stage I have selected three indicators for building a trading strategy as an example:. At the second stage we will discover a way of using selected instruments, conditions for their operation, and also the position parameters for market entry.

All we need to do is to determine how to exit the position. As a condition for exiting, we will set the price target that we have obtained earlier: So, our trading strategy is now defined. We have set the conditions for opening and closing positions, selected the indicators and set their operational parameters, defined the sizes of position entry and their goals. And, finally, we have decided on the events for exiting the market. At the next stage we are going to check the created trading strategy in real conditions.

The first thing we need to understand is that there are no ideal strategies in a long-term perspective and absolutely all market stages. And traders that use automated trading and those who trade manually frequently observe that their system proves itself differently in various conditions. Also, it is not unusual when the initial conditions in the already specified trading system could have shown better results.

For example, with respect to our system, a trader may have noticed that the set Take Profit could have been made higher. This is not because he simply wishes to gain more, but because he constantly analyzes his system, and his statistics showed that after closing successful trades, the price kept moving in the desired direction for some time.

Therefore a trader may have a reasonable question: Let's look at the indicators used in our system from the perspective of fuzzy logic theory. In my previous article I tried to convey its main advantage — flexibility in analyzing those parts of the trading strategy where strict categorization applies. Fuzzy logic was blurring strict boundaries giving a broader picture of evaluation and reaction of the system in the border sections of its operation. There was also an example of a more adaptable approach to the operation of the ADX indicator we used.

First, a strict division between weak, average and strong trends was applied, but then these categories blurred and determining the trend strength wasn't already strictly linked to the subjectivity of the indicator values. Imagine that our trader observes the market and sees the signal from his first indicator: ADX has reached 32, for example. He marks this and waits for confirmation from other two indicators.

Shortly the signal from AC arrives, while ADX shows increase for up to The RVI signal line crosses the main line after some time, which means that all three conditions for entering the position have been finally met.

ADX has already reached the 45 point. But the absolute value of ADX in our system is not so important. The main thing is that it exceeds Therefore a trader follows his rules and enters the market with 0,01 lot, Take Profit at 50 points, and Stop Loss at Now, let's simulate another possible scenario. In the beginning, the situation develops the same way as in the first case.

But when the last missing signal for opening the position arrives from RVI, then ADX rockets to 55, instead of By comparing the two described options, it shows that the second signal is stronger than the previous one, but our trader still opens the position with the same lot and the same values of Take Profit and Stop Loss.

Here we encounter the first disadvantage of our strategy. Only the existence of the incoming signal is evaluated, without paying much attention to quality.

And even if we manage to evaluate and define the category, the accuracy of the assessment still will be lost in transitional areas. So how can we approve a particular case with ADX, RVI indicators and bind their parameters to the position we use for market entry? For this purpose, we need to carry out the following steps:.

We will set 4 categories of trend strength: This is how it will look:. Visual trend strength divided in categories. In order to set the categories of the output signal, it is required to determine how the ADX category will influence our position.

Normally, the higher the trend is, the longer it lasts. Therefore, we will proceed accordingly: The following categories will be entered for the profit goal value that will be added to the initial 50 points of our strategy.

At the following stage we will describe the conditions set earlier with membership functions of fuzzy set theory. The description of four trend categories is as follows:. Description of four trend categories of fuzzy logic. As shown in fig. Let's set the categories for Relative Vigor Index.

There will be four: Visual division of Relative Vigor Index by category. Now, we will describe the categories introduced with membership functions. Trapezium functions will be used to describe low and higher categories, and triangular functions will apply as for medium and high categories. Description of RVI index categories.

Similarly, we will describe four categories for values of profit goals: This is how the description of our input signal would look like. Description of categories for values of profit goals.

The general appearance of the trading strategy in full implementation will look as follows fig. Full implementation, general appearance, and setting of the trading strategy. Now let's look into this panel implementation using MQL4 tools and FuzzyNet library. We define the initial properties and connect the library to operate with fuzzy logic.

forex fuzzy in logic trading rules

We will set the option to find the panel in the chart's window. We will define one indicator buffer and its color green for an arrow indicator of the bar we analyzed.

We will look into the first block of input Parameters in more details. It contains the following elements:. The second block of input Fuzzy Logic Parameters contains the majority of parameters for flexible settings of all membership functions describing both input ADX trend strength, RVI index and output parameters recommended value of profit goal points. In the next block we declare variables, names of headings, the actual template of the info panel size, location, font and other , and set the parameters of displaying the element indicating the current bar the arrow in our case.

Now, let's have a look at the main block of processing signals from the ADX and RVI indicators. The conditions are set under which indicator values satisfy the buy and sell signals. When they match, values are handled with the mamdani double t, double v function and displayed in the panel. All this has the following form: The function creates the fuzzy logic system.

It contains two input signals from the indicators — trend and vigor each of them consists of four terms described by membership functions , and one output signal. Four rules that input and output signals are connected with are also included in the system. Let's proceed to the final block — "Additional functions".

The second one defines the number of signs in the current currency instrument. I would also like to draw your attention to the correctness of settings and re-verification of the parameter correctness in the section Fuzzy Logic Parameters while testing.

I recommend to rely on their initial graphic representation in the fig. Translated from Russian by MetaQuotes Software Corp.

This article describes a process of creating an Expert Advisor for MetaTrader 4 based on the Engulfing pattern, as well as the pattern recognition principle, rules of setting pending orders and stop orders.

The results of testing and optimization are provided for your information. This article provides an answer to the question: The article details TD points and TD lines discovered by Thomas DeMark. Their practical implementation is revealed. In addition to that, a process of writing three indicators and two Expert Advisors using the concepts of Thomas DeMark is demonstrated. It is essential to detect whether a market is flat or not for many strategies.

Using the well known ADX we demonstrate how we can use the Strategy Tester not only to optimize this indicator for our specific purpose, but as well we can decide whether this indicator will meet our needs and get to know the average range of the flat and trend markets which might be quite important to determine stops and targets of the markets.

MetaTrader 5 Examples Indicators Experts Tester Trading Trading Systems Integration Indicators Expert Advisors Statistics and analysis Interviews MetaTrader 4 Examples Indicators Experts Tester Trading Trading Systems Integration Indicators Expert Advisors Statistics and analysis.

MetaTrader 4 — Trading. Introduction A rapid development of technology has led to a stronger tendency of using automated trading systems on modern currency markets. Selecting manual strategy with a specific formalization of conditions Many modern traders choose to take responsibility for entering and exiting positions, rather than rely on automated systems. Finding and identifying instruments that will be used for our strategy.

Setting specific conditions used by a trader to open a position on the market. Setting specific conditions when a position will have to be closed with either positive or negative result. At the first stage I have selected three indicators for building a trading strategy as an example: Average Directional Movement Index, ADX. This is a trending indicator that determines the strength of the current trend.

Fuzzy logic to create manual trading strategies - MQL4 Articles

Relative Vigor Index, RVI oscillator. Accelerator Oscillator AC indicator by Bill Williams. Selected general view and settings of the MQL4 trading terminal: General view of strategy settings Stage No2.

Let's start from the beginning. Our first indicator is ADX. As seen from the fig. Furthermore, a level for the main trend line green color that equals 30 was set specifically. Any value that equals or exceeds it, will be considered as a positive signal for market entry. The second indicator is AC. Here we are going to use signals described in the official documentation. Specifically, if the indicator's value is below 0 and it grows on the analyzed and two previous bars, then it's a signal for buying.

Therefore, if the indicator's value is above 0 and it falls on the analyzed and two previous bars, we get a signal for selling. The third indicator is RVI. Let's set the period of its operation equal to As a condition for buying, we will determine the moment when the signal line thin red crosses the main line green. At this intersection, the line's value on the analyzed bar must be below the zero point. Similarly, we will set conditions for selling: The next condition for an operation will be an hourly timeframe H1.

The condition for position entry implies passing similar signals from all three selected indicators. And, finally, we will decide on the size of the position. As an example, the following will be set: Terms will be formalized for a better clarity. AC value grows on the current bar, and is higher than on the previous two bars that also grow consistently.

Visually, these are three columns of the green histogram, where each column is shorter than the previous one, and all three are positioned in the negative area. The RVI signal thin red line crosses the main line green , both grow, but still remain below the zero point. We buy with 0,01 lot, place Take Profit of 50 points and Stop Loss of 30 points. The AC value drops at the current bar, and is lower than at the previous two bars that keep dropping consistently.

Visually, these are three columns of the red histogram, where each column is shorter than the previous one, and values of all three are above zero.

The RVI signal line thin red crosses the main line green , both decline but remain in the positive area. We sell with 0,01 lot, place Take Profit of 50 points and Stop Loss of 30 points Stage No3 All we need to do is to determine how to exit the position. Remedying the shortcomings of strict formalization with fuzzy logic Let's look at the indicators used in our system from the perspective of fuzzy logic theory. But let's return to our system and ask ourselves: For this purpose, we need to carry out the following steps: To establish clear categories of evaluating the trend strength ADX and Relative Vigor Index RVI.

This will be an input signal, based on which we will make an additional decision. To establish clear categories of our position's goals Take Profit or Stop Loss in our strategy, although we can set here a lot size. This is an output signal that will correct our position on the market given the trend strength.

To describe categories of input and output signals with membership functions of fuzzy set theory. To create interface that would display recommendations for changing a position of the initial strategy based on the new terms. To create flexible settings for changing membership functions that would allow to correct this recommendation system when necessary. To start with, we will describe the first input variable — value of trend strength.

This is how it will look: Visual trend strength divided in categories 2. The description of four trend categories is as follows: Description of four trend categories of fuzzy logic As shown in fig.

Now, let's define the same for the RVI. Visual division of Relative Vigor Index by category 2. Description of RVI index categories Similarly, we will describe four categories for values of profit goals: Only when specified criteria is satisfied, for instance — 30 or above. Only provided that it's higher than 0,1 for sale signal , or below -0,1 for buy signal. The recommended number of points that must be added to the initial goal of Take Profit value in the format of trading instrument's price taking into account the initial price and recommendations on how to increase it.

Full implementation, general appearance, and setting of the trading strategy Now let's look into this panel implementation using MQL4 tools and FuzzyNet library. We implement and analyze the key logical blocks of this informative panel with MQL4 tools.

It contains the following elements: Conclusion In conclusion, we are going to summarize what we've learned. The first part of work for creating a manual trading strategy with fuzzy logic lies in the development of strictly formalized rules of this strategy. This was examined at the stages No1 — No3. Then it is necessary to find disadvantages of the strict formalization where strict categorization of any estimated blocks or parameters applies. In the example provided, a part of the strategy that didn't allow us to determine the moment of market entry with enough flexibility was found.

Further, all clear categories are described using fuzzy set theory and, thus, become more flexible. Now, in the boarder values there may be a belonging to not just one specific category as before, but to both simultaneously to a different extent.

Download - UpdateStar - ucujaluxu.web.fc2.com

This strategy is implemented in the form of the indicator, panel or alert. In this article, a panel in MQL4 language was selected. We have considered the opportunity to improve the manual trading strategy by applying fuzzy set theory. Using the example revealed more details on how the already formed trading strategy is modified and complemented by applying fuzzy logic and getting rid of the flaws discovered. Attached files Download ZIP. All rights to these materials are reserved by MQL5 Ltd.

Copying or reprinting of these materials in whole or in part is prohibited. Last comments Go to discussion 6. Rasoul Mojtahedzadeh 7 Mar at Alexander Fedosov 8 Mar at You need to download FuzzyLogic Lib for MQL4 from CodeBase and install it on your platform. Sherif Hasan 9 Apr at Automating the Engulfing Pattern Trading Strategy This article describes a process of creating an Expert Advisor for MetaTrader 4 based on the Engulfing pattern, as well as the pattern recognition principle, rules of setting pending orders and stop orders.

How to Develop a Profitable Trading Strategy This article provides an answer to the question: Thomas DeMark's contribution to technical analysis The article details TD points and TD lines discovered by Thomas DeMark.

Enhancing the StrategyTester to Optimize Indicators Solely on the Example of Flat and Trend Markets It is essential to detect whether a market is flat or not for many strategies.

inserted by FC2 system