### Math Guide for Forex Trading,jMathFx Webinar Program

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':.

С1 and С2 events form an exhaustive group of antithetic events i. one of these events occurs in any case. 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. To do this, I will introduce the С3, С4 event space, in which the first event is closing by stop levels, while the second one is closing by 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.

Since the combinations can be made both by ascending and descending segments, this inevitably leads to déjà vu. 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. When you make this decision you have to decide where to place the stop-loss. Take a look where the most current swings are.

Find support and resistance points. When you settle a level where you want to place stop-loss, you have to measure the distance in pips between this level and the entry you plan. Write down that number. Then, discover the value of each pip. And you can calculate your position size. The distance between entry and stop is pips. This is just an example and you will find different situations but the principle is the same. Save my name, email, and website in this browser for the next time I comment.

FREE Price Action PDF Home Start Here Trading Dictionary About Contact. The math concepts that are simple and easy to learn. When unsure what's the right move, you can always trade Forex Get the number 1 winning technical analysis ebook for trading Forex to your email.

Containing the full system rules and unique cash-making strategies. You'll be surprised to see what indicators are being used and what is the master tuning for successful trades. Including case-studies and images. Forex Forex trading pip. Leave a Comment Cancel reply Name. Currency correlations can be positive, meaning that two currency pairs move in the same direction.

Currency correlations can be negative, meaning that two currency pair move in opposite directions. And finally, currency correlation can be neutral, meaning there is no discernible price relationship between the two currency pairs. The forex mathematics behind currency correlation can be quite complicated, so we will not get into that in this lesson. But fortunately for us, we do not need to know the trade math because there are many currency correlation tools available in the market that makes it easy for use to do our correlation analysis.

Most currency correlation tools are presented in a table format. Remember that a positive value means that the pairs move in the same direction, while a negative value means they have an inverse relationship. As traders, we know that we will have losing trades and that they are a natural part of trading.

Essentially, maximum drawdown is the maximum loss in equity that our portfolio incurs over a period of time. It is the largest drop from a previous equity peak to the lowest point after the peak. We can calculate the maximum drawdown after a new peak has been put in place on the equity curve. Here is the math formula for calculating Maximum Drawdown:. What is your Maximum Drawdown in this scenario?

So, the Max Drawdown in this case is Drawdowns can be very dangerous to the financial health of a trader because, as your drawdown increases the return needed to recover becomes larger and larger. Let take a look at the table below:. As you can see, the larger the max drawdown or capital loss the higher the percentage gain is needed to recover the losses.

This is one reason why it is critical for traders to trade small so that they can try to keep drawdowns to a tolerable level. I would venture to guess that most retail traders have either never heard of Risk of Ruin or if they have they do not really understand its power when it comes to risk analysis in the markets.

Risk of Ruin is the likelihood or probability that a trader will lose a predetermined amount of trading capital wherein they will not be able to continue trading. It could be any percentage that the trader determines will be the point at which they will stop trading a system.

The Risk of Ruin is calculated as follows:. There are several simulators available for free that you can use to calculate the risk of ruin. The one we will use in our example can be found here. We will use the following assumptions and plug that into the Risk of Ruin simulator:. If you hit calculate on the simulator, it will run the simulations again so the ROR number may vary a bit.

Well the factor that we would have the most control over is the Risk amount, and so we should look to adjust that input. Ok so we will keep all the variables the same, except we will adjust the Risk amount to 2. What does that do? Well that looks like a winner. Profit Factor measures the profitability of your trading system or strategy. It is one of the most simple but useful metrics related to system performance.

Profit Factor can be calculated in one of two ways:. A profit factor of less than 1 means that the trading strategy is a losing strategy. A profit factor of 1 to 1. A profit factor of 1. A profit factor above 2 means that the trading strategy is extremely profitable.

For many of us, math has never been our greatest strength. In fact, the mere idea of using math formulas for trading is something that garners fear in many traders.

In this lesson, we will be discussing some of the more important math formulas that every trader should learn and have a good understanding of if they want to succeed in the market. But the good news is that most of these trade related math concepts are actually fairly simple and easy to understand even for those that are mathematically challenged.

Movement in currency pairs are measured in pips. Within the currency exchange rate, the minimum pip can be seen in the fourth digit after the decimal place for most currency pairs. The exception to this rule are Yen pairs wherein their minimum pip can be seen in the second digit after the decimal place. Depending on which currency pair you are trading, the value of a pip will be differ.

It is also important to note that a standard lot is , units of a currency. A mini lot is 10, units of a currency, and a micro lot is 1, units of a currency. You can use the forex math formula below to calculate the pip value of a currency pair:. Many novice forex traders tend to confuse margin and leverage. Though they are closely tied, you should understand the difference between the two, and know how to calculate each.

So, what is leverage in trading? Leverage gives a trader the ability to control a larger position by using a small portion of their own funds and borrowing the rest from their broker.

What is Margin? Margin is the good faith deposit required by your broker to allow you to open a position. Using these funds coupled with other client funds, the broker can then place trades with their liquidity providers and interbank partners. Leverage can be calculated using the forex trading math formula below:.

So, the effective leverage in this example would be expressed as Brokers in the United States offer upto leverage for forex trading, while Forex brokers in other jurisdictions can offer leverage upto in some cases. But is very important to keep in mind that leverage should be used responsibly as it acts to not only amplify returns, but also magnifies losses. Position Sizing is one of the most important and frequent calculations that you will need to make as a forex trader.

In fact, before any trade that you consider entering into, you should calculate the proper position size based on your pre-defined position sizing model. One of the simplest and most effective position sizing models is a fixed fractional model.

Once you have determined how much you plan to risk on a per trade basis, then you would start by determining where the most logical stop should be placed on a particular trade. One you have located a level where you plan on placing your stop loss , measure the distance in pips between this level and your intended entry. Then jot that number down and keep it handy. Now the next step is to determine the value of each pip.

We have discussed how to calculate the value of a pip in the previous section. Once you have this value, you are ready to calculate your position size.

Here is the trading math behind Position Sizing:. Trade Expectancy is one of the most important metrics that a trader should be aware of. But what does it mean? In a nutshell, trade expectancy is the average profit or loss that can be expected on each trade based on your average Win Percentage, Avg Win Size and Avg Loss Size. Here is the mathematical formula for Trade Expectancy:.

Typically trend following systems tend to have low win rates, but relatively large average wins compared to average losses. This time we will look at a Mean Reversion strategy. Mean reversion strategies tend to have higher win rates, and the average wins and losses are somewhat similar. Many traders make the mistake of only relying on win rates when evaluating trading systems. How many times have you entered positions in multiple currency pairs and noticed that their price movements were related?

To understand this better, you have to know what currency correlation is and how it can impact the overall risk in your portfolio. Currency correlation is a statistical measure of how different currency pairs move in relationship to each other. Currency correlations can be positive, meaning that two currency pairs move in the same direction. Currency correlations can be negative, meaning that two currency pair move in opposite directions.

And finally, currency correlation can be neutral, meaning there is no discernible price relationship between the two currency pairs. The forex mathematics behind currency correlation can be quite complicated, so we will not get into that in this lesson. But fortunately for us, we do not need to know the trade math because there are many currency correlation tools available in the market that makes it easy for use to do our correlation analysis.

Most currency correlation tools are presented in a table format. Remember that a positive value means that the pairs move in the same direction, while a negative value means they have an inverse relationship.

As traders, we know that we will have losing trades and that they are a natural part of trading. Essentially, maximum drawdown is the maximum loss in equity that our portfolio incurs over a period of time. It is the largest drop from a previous equity peak to the lowest point after the peak. We can calculate the maximum drawdown after a new peak has been put in place on the equity curve.

Here is the math formula for calculating Maximum Drawdown:. What is your Maximum Drawdown in this scenario? So, the Max Drawdown in this case is Drawdowns can be very dangerous to the financial health of a trader because, as your drawdown increases the return needed to recover becomes larger and larger.

Let take a look at the table below:. As you can see, the larger the max drawdown or capital loss the higher the percentage gain is needed to recover the losses. This is one reason why it is critical for traders to trade small so that they can try to keep drawdowns to a tolerable level.

I would venture to guess that most retail traders have either never heard of Risk of Ruin or if they have they do not really understand its power when it comes to risk analysis in the markets. Risk of Ruin is the likelihood or probability that a trader will lose a predetermined amount of trading capital wherein they will not be able to continue trading. It could be any percentage that the trader determines will be the point at which they will stop trading a system.

The Risk of Ruin is calculated as follows:. There are several simulators available for free that you can use to calculate the risk of ruin. The one we will use in our example can be found here. We will use the following assumptions and plug that into the Risk of Ruin simulator:.

If you hit calculate on the simulator, it will run the simulations again so the ROR number may vary a bit. Well the factor that we would have the most control over is the Risk amount, and so we should look to adjust that input. Ok so we will keep all the variables the same, except we will adjust the Risk amount to 2. What does that do? Well that looks like a winner.

Profit Factor measures the profitability of your trading system or strategy. It is one of the most simple but useful metrics related to system performance. Profit Factor can be calculated in one of two ways:. A profit factor of less than 1 means that the trading strategy is a losing strategy. A profit factor of 1 to 1. A profit factor of 1. A profit factor above 2 means that the trading strategy is extremely profitable.

Can you figure out the Profit Factor of this system? This system has a Profit Factor of 1. This system has a Profit Factor of 0,97, meaning that this is a losing strategy. The concept of R Multiples was first introduced by renown psychologist Dr.

Van Tharp. R Multiple sounds like an esoteric term but it is fairly straightforward and easy to understand. R Multiple essentially measures Risk to Reward for a particular trade. R stands for Risk and is usually denoted as 1R the risk in the trade. The multiple of R is your reward as compared to your Risk. So, a 3R trade for example, would simply mean that for every unit of risk you are taking, your potential profit is 3 times that risk or 3R.

As you can see by using R multiples, it allows us to standardize our risk measures and easily gauge the Risk profile of a trade. A trade with a 50 pip stop and pip target is a 2R trade. A trade with a 70 pip stop and a pip target is a 3R trade. A trade with a pip stop and a 60 pip target is a 0. I think you get the basic gist of it now.

By combining the Risk to Reward and using the R Multiple we can quickly and easily assess the viability of a trade setup and the potential payoff. You can use R Multiples beyond single trade events also.

For example, R Multiples can be used to express Portfolio performance, Max Drawdown as well as other related trade metrics. Basically, you would view these metrics from the lens of 1 unit of risk.