Окт22012

# Forex maths

*Taran*

*Cobra for forex комментариев 5*

**DOWNLOAD FOREX ROBOTS**Public-key authentication uses a workaround if a schedule when and accordingly implement. The best answers match the AC application that allows to establish Remote. Levels to get product documentation for.

The trade expectancy is quite important in trading, that is why each trader should know about it. However, what does it mean? Briefly speaking, the trade expectancy is an average size of profit or loss, which might be expected from a trade on the basis of statistical indicators of your trading system. Below is a mathematical formula of calculation of this indicator:.

Percentage of profit-making trades x Average increase from a profit-making trade — Percentage of loss-making trades x Average decrease from a loss-making trade. Now, we will consider the trade expectancy close using an example of statistical data of a standard trend following trading system. As a rule, the trend following trading system is characterized with a low percentage of profit-making trades, but also with a relatively higher average increase from a profit-making trade compared to an average decrease from a loss-making trade.

Thus, the considered trend following trading system is characterized with the trade expectancy of USD Now we consider one more example. As a rule, this strategy has a higher percentage of profit-making trades and an average increase from a profit-making trade and average decrease from a loss-making trade are approximately equal.

Thus, the considered mean reversion trading strategy is characterized with the trade expectancy of USD , which is an average value of the expected profit from each executed trade. Many traders do it wrongly when they assess efficiency of a trading system based on the percentage of profit-making trades only. As you can see now, this indicator is just one of the several indicators, which are used in the formula of calculation of the trade expectancy.

How often did you execute trades by several currency pairs at once and notice that their price quote movements were interconnected? Correlation of currencies is a statistical indicator, which describes movements of currency pairs with respect to each other. Currency correlations could be positive, which means movement of the price quotes of two currencies in one direction both grow or fall.

They can also be negative, which means price quote movement of two currency pairs in different directions one grows, while the other falls, and vice versa. Besides, the correlation of currency pairs could be neutral, which means absence of any noticeable interconnection between movements of price quotes of two currency pairs.

The order of calculation of currency correlations is rather complex, that is why we will not speak about it in this article. However, fortunately for us, there is no need to do it. There are many indicators that serve this purpose. They automatically calculate correlation indicators and reflect their resulting values in a table form. The below ranges of currency correlations would help you to identify how currency pairs move with respect to each other easily and quickly:.

Remember that positive values tell us that currency pairs move in the same direction, while negative ones tell us that the pairs move in different directions. What if we go further and use a USD index futures chart for identifying future movements of the basic currency pairs? In this case, a USD index futures will play the role of a leading indicator.

You can read about this method of simple and efficient market analysis in our article USD index: 8 things you should know. Part 2. We will continue to introduce important mathematical formulas, which any trader who trades in the Forex market should have in his arsenal, to you in the second part of the article.

If you are a beginner Forex trader, pursue the price and still wondering how to predict futures movements of currency pairs, we recommend you to read the Strategy of footprint use based on a currency futures example article. You can find useful advice about how to use advanced instruments of the trading and analytical ATAS platform for more efficient analysis of the currency market in this and other similar articles.

Use the link at the beginning of the article to download the ATAS platform absolutely free of charge. Happy trading! Your Registration was successful. The login credentials have been sent to your e-mail. You already have access to the ATAS platform.

Please use the login you have previously been provided. You already have full access to the ATAS platform which supports this challenge. Please use the login credentials you have previously been. Part 1. Core mathematics for Forex traders. In this article: Cost of a pip price interest point ; Margin and leverage; Size of a position; Trade expectancy; Correlation of currencies. Movement of currency pairs in the Forex market is measured in pips. Below is a mathematical formula of calculation of this indicator: Percentage of profit-making trades x Average increase from a profit-making trade — Percentage of loss-making trades x Average decrease from a loss-making trade.

The below ranges of currency correlations would help you to identify how currency pairs move with respect to each other easily and quickly: 0 — 0. Did you like it? Tell your friends:. Other blog articles:. X This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. Manage consent. Close Privacy Overview This website uses cookies to improve your experience while you navigate through the website.

Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.

Necessary Necessary. Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously. Cookie Duration Description. This cookie is used to prevent request forgery ATAS. Billing 10 day Authorized user token aviaCookieConsent 1 year This cookie indicates that you agree to our use of cookies on our website aviaPrivacyEssentialCookiesEnabled 1 day This cookie indicates that you agree to our use of cookies on our website aviaPrivacyRefuseCookiesHideBar 1 day This cookie indicates that you agree to our use of cookies on our website BillingAuthorized 10 day This cookie is used to show if the user is logged in bulkTime 1 year Wordpress ShortPixel Image Optimizer cookielawinfo-checkbox-advertisement 1 year Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category.

The cookie is used to store the user consent for the cookies in the category "Analytics". The cookies is used to store the user consent for the cookies in the category "Necessary". The cookie is used to store the user consent for the cookies in the category "Other cookielawinfo-checkbox-performance 11 months This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance" language session This cookie is used to store the language preference of the user LanguageSwitcher session This cookie is used to save the user's language preferences oftinf never This cookie is used to record the id of the partner who brought the user PHPSESSID session This cookie is native to PHP applications.

The cookie is used to store and identify a users' unique session ID for the purpose of managing user session on the website. It does not store any personal data. Analytics analytics. Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc. This ensures that the behaviour is applied to the same user identifier on subsequent visits to the same website.

This information is used to evaluate the effectiveness of advertising on websites. Using the chat functionality, this allows the website to purposefully offer the relevant offers to the user c. This information is used to optimize the relevance of advertising on the website. Marketing advertisement.

Marketing cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads. This cookie is necessary forwebsite complianceGDPR fr 3 months Facebook sets this cookie to show relevant advertisements to users by tracking user behaviour across the web, on sites that have Facebook pixel or Facebook social plugin.

It isused to evaluate advertising effortsand facilitate the payment ofreferral rewards between websites Remixlang 1 year It defines the visitor's preferredlanguage. Others others. Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

Cookie Duration Description ls-popup 1 year It is a cookie that allows to remember how many times a popup has been displayed ls-popup-last-displayed 2 years It is a cookie that allows to remember how many times a popup has been displayed qmb session No description remixir past No description. Powered by. When discussing level-based trading, traders usually mean using limit order levels. All this can be briefly displayed as follows. What we see in the MetaTrader window is a discrete function of the t argument, where t is time.

The function is discrete because the number of ticks is finite. In the current case, ticks are points containing nothing in between. Ticks are the smallest elements of possible price discretization, larger elements are bars, M1, M5, M15 candles, etc. The market features both the element of random and patterns.

The patterns can be of various scales and duration. However, the market is for the most part a probabilistic, chaotic and almost unpredictable environment. To understand the market, one should view it through the concepts of the probability theory. Discretization is needed to introduce the concepts of probability and probability density.

To introduce the concept of the expected payoff, we first need to consider the terms 'event' and 'exhaustive events':. This equation may turn out to be handy later. While testing an EA or a manual strategy with a random opening, as well as random StopLoss and TakeProfit, we still get one non-random result and the expected payoff equal to "- Spread ", which would mean "0", if we could set the spread to zero.

This suggests that we always get the zero expected payoff on the random market regardless of stop levels. On the non-random market, we always get a profit or loss provided that the market features related patterns. We can reach the same conclusions by assuming that the expected payoff Tick[0].

Bid - Tick[1]. Bid is also equal to zero. These are fairly simple conclusions that can be reached in many ways. This is the main chaotic market equation describing the expected payoff of a chaotic order opening and closing using stop levels. After solving the last equation, we get all the probabilities we are interested in, both for the complete randomness and the opposite case, provided that we know stop values. The equation provided here is meant only for the simplest case that can be generalized for any strategy.

This is exactly what I am going to do now to achieve a complete understanding of what constitutes the final expected payoff we need to make non-zero. Also, let's introduce the concept of profit factor and write the appropriate equations. Assume that our strategy involves closing both by stop levels and some other signals. They also form a complete group of antithetic events, so we can use the analogy to write:.

In other words, we have two antithetic events. Their outcomes form another two independent event spaces where we also define the full group. However, the P1, P2, P0[i] and P01[j] probabilities are conditional now, while P3 and P4 are the probabilities of hypotheses.

The conditional probability is a probability of an event when a hypothesis occurs. Everything is in strict accordance with the total probability formula Bayes' formula. I strongly recommend studying it thoroughly to grasp the matter. Now the equation has become much clearer and broader, as it considers closing both by stop levels and signals. We can follow this analogy even further and write the general equation for any strategy that takes into account even dynamic stop levels.

This is what I am going to do. Let's introduce N new events forming a complete group meaning opening deals with similar StopLoss and TakeProfit. The most you can do is change the strategy but if it contains no rational basis, you will simply change the balance of these variables and still get 0. In order to break this unwanted equilibrium, we need to know the probability of the market movement in any direction within any fixed movement segment in points or the expected price movement payoff within a certain period of time.

If you manage to find them, then you will have a profitable strategy. Now let's create the profit factor equation. The profit factor is the ratio of profit to loss. If the number exceeds 1, the strategy is profitable, otherwise, it is not. This can be redefined using the expected payoff.

This means the ratio of the expected net profit payoff to the expected net loss. Let's write their equations. In fact, these are the same equations, although the first one lacks the part related to loss, while the second one lacks the part related to profit. M and PrF are two values that are quite sufficient to evaluate the strategy from all sides. In particular, there is an ability to evaluate the trend or flat nature of a certain instrument using the same probability theory and combinatorics.

Besides, it is also possible to find some differences from randomness using the probability distribution densities. I will build a random value distribution probability density graph for a discretized price at a fixed H step in points. Let's assume that if the price moves H in any direction, then a step has been taken. The X axis is to display a random value in the form of a vertical price chart movement measured in the number of steps.

In this case, n steps are imperative as this is the only way to evaluate the overall price movement. To provide the total "s" steps upwards the value can be negative meaning downward steps , a certain number of up and down steps should be provided: "u", "d". The final "s" up or down movement depends on all steps in total:. However, not all "s" values are suitable for a certain "n" value. The step between possible s values is always equal to 2. This is done in order to provide "u" and "d" with natural values since they are to be used for combinatorics, or rather, for calculating combinations.

If these numbers are fractional, then we cannot calculate the factorial, which is the cornerstone of all combinatorics. Below are all possible scenarios for 18 steps. The graph shows how extensive the event options are. There is no need to try to grasp each of these options, as it is impossible. Instead we just simply need to know that we have n unique cells, of which u and d should be up and down, respectively.

The options having the same u and d ultimately provide the same s. In case of different u and d, we obtain the same value of C. So what segments should we use to form combinations? The answer is any, as these combinations are equivalent despite their differences.

I will try to prove this below using a MathCad based application. Now that we have determined the number of combinations for each scenario, we can determine the probability of a particular combination or event, whatever you like. This value can be calculated for all "s", and the sum of these probabilities is always equal to 1, since one of these options will happen anyway. Based on this probability array, we are able to build the probability density graph relative to the "s" random value considering that s step is 2.

In this case, the density at a particular step can be obtained simply by dividing the probability by the s step size, i. The reason for this is that we are unable to build a continuous function for discrete values. This density remains relevant half a step to the left and right, i. It helps us find the nodes and allows for numerical integration.

For negative "s" values, I will simply mirror the graph relative to the probability density axis. For even n values, numbering of nodes starts from 0, for odd ones it starts from 1. In case of even n values, we cannot provide odd s values, while in case of odd n values, we cannot provide even s values. The calculation application screenshot below clarifies this:. It lists everything we need.

The application is attached below so that you are able to play around with the parameters. One of the most popular questions is how to define whether the current market situation is trend or flat-based. I have come up with my own equations for quantifying the trend or flat nature of an instrument. I have divided trends into Alpha and Beta ones. Alpha means a tendency to either buy or sell, while Beta is just a tendency to continue the movement without a clearly defined prevalence of buyers or sellers.

Finally, flat means a tendency to get back to the initial price. The definitions of trend and flat vary greatly among traders. I am trying to give a more rigid definition to all these phenomena, since even a basic understanding of these matters and means of their quantification allows applying many strategies previously considered dead or too simplistic. Here are these main equations:.

The first option is for a continuous random variable, while the second one is for a discrete one. I have made the discrete value continuous for more clarity, thus using the first equation. The integral spans from minus to plus infinity. This is the equilibrium or trend ratio. After calculating it for a random value, we obtain an equilibrium point to be used to compare the real distribution of quotes with the reference one.

We can calculate the maximum value of the ratio. We can also calculate the minimum value of the ratio. The KMid midpoint, minimum and maximum are all that is needed to evaluate trend or flat nature of the analyzed area in percentage. But this is still not enough to fully characterize the situation. It essentially shows the expected payoff of the number of upward steps and is at the same time an indicator of the alpha trend.

If we measure the alpha trend percentage from to , we may write equations for calculating the value similar to the previous one:. If the percentage is positive, the trend is bullish, if it is negative, the trend is bearish. The cases may be mixed. There may be an alpha flat and alpha trend but not trend and flat simultaneously. Below is a graphical illustration of the above statements and examples of constructed density graphs for various number of steps.

As we can see, with an increase in the number of steps, the graph becomes narrower and higher. For each number of steps, the corresponding alpha and beta values are different, just like the distribution itself. When changing the number of steps, the reference distribution should be recalculated. All these equations can be applied to build automated trading systems.

These algorithms can also be used to develop indicators. Some traders have already implemented these things in their EAs. I am sure of one thing: it is better to apply this analysis rather than avoid it. Those familiar with math will immediately come up with some new ideas on how to apply it. Those who are not will have to make more efforts. Here I am going to transform my simple mathematical research into an indicator detecting market entry points and serving as a basis for writing EAs.

I will develop the indicator in MQL5. However, the code is to be adapted for porting to MQL4 for the greatest possible extent. Generally, I try to use the simplest possible methods resorting to OOP only if a code becomes unnecessarily cumbersome and unreadable. Unnecessarily colorful panels, buttons and a plethora of data displayed on a chart only hinder the visual perception. Instead, I always try to do with as little visual tools as possible. When the indicator is loaded, we are able to carry out the initial calculation of a certain number of steps using certain last candles as a basis.

We will also need the buffer to store data about our last steps. The new data is to replace the old one. Its size is to be limited. The same size is to be used to draw steps on the chart. We should specify the number of steps, for which we are to build distribution and calculate the necessary values. Then we should inform the system of the step size in points and whether we need visualization of steps.

Steps are to be visualized by drawing on the chart. I have selected the indicator style in a separate window displaying the neutral distribution and the current situation. There are two lines, although it would be good to have the third one. Unfortunately, the indicators capabilities do not imply drawing in a separate and main windows, so I have had to resort to drawing.

Now the code is made compatible with MQL4 as much as possible and we are able to turn it into an MQL4 analogue quickly and easily. Additionally, we will need a point to count the next step from. The node stores data about itself and the step that ended on it, as well as the boolean component that indicates whether the node is active.

Only when the entire memory of the node array is filled with real nodes, the real distribution is calculated since it is calculated by steps. No steps — no calculation. Further on, we need to have the ability to update the status of steps at each tick and carry out an approximate calculation by bars when initializing the indicator.

Next, describe the methods and variables necessary to calculate all neutral line parameters. Its ordinate represents the probability of a particular combination or outcome. I do not like to call this the normal distribution since the normal distribution is a continuous quantity, while I build the graph of a discrete value. Besides, the normal distribution is a probability density rather than probability as in the case of the indicator. It is more convenient to build a probability graph, rather than its density.

All these functions should be called in the right place. All functions here are intended either for calculating the values of arrays, or they implement some auxiliary mathematical functions, except for the first two. They are called during initialization along with the calculation of the neutral distribution, and used to set the size of the arrays. Next, create the code block for calculating the real distribution and its main parameters in the same way. Here all is simple but there are much more arrays since the graph is not always mirrored relative to the vertical axis.

To achieve this, we need additional arrays and variables, but the general logic is simple: calculate the number of specific case outcomes and divide it by the total number of all outcomes. This is how we get all probabilities ordinates and the corresponding abscissas. I am not going to delve into each loop and variable.

All these complexities are needed to avoid issues with moving values to the buffers. Here everything is almost the same: define the size of arrays and count them. Next, calculate the alpha and beta trend percentages and display them in the upper left corner of the screen. CurrentBuffer and NeutralBuffer are used here as buffers. For more clarity, I have introduced the display on the nearest candles to the market. Each probability is on a separate bar.

This allowed us to get rid of unnecessary complications. Simply zoom the chart in and out to see everything. The CleanAll and RedrawAll functions are not shown here. They can be commented out, and everything will work fine without rendering.

Also, I have not included the drawing block here. You can find it in the attachment. There is nothing notable there. The indicator is also attached below in two versions — for MetaTrader 4 and MetaTrader 5. I have developed and seen plenty of strategies.

In my humble experience, the most notable things happen when using a grid or martingale or both. Strictly speaking, the expected payoff of both martingale and grid is 0. Do not be fooled by upward-going charts since one day you will get a huge loss. There are working grids and they can be found in the market. They work fairly well and even show the profit factor of This is quite a high value.

Moreover, they remain stable on any currency pair. But it is not easy to come up with filters that will allow you to win. The method described above allows you to sort these signals out.