When “Use Previous Bar Value” option is activated, we use the value of an indicator from the previous bar for a logical criterion concerning the current trade. The purpose of this concept is to make a backtest reliable.
Let us see the following example:
We have the following trading rules (We'll see an example for long trade only.):
To be clearer, I marked the bars as follows:
The corresponding MACD values are:
The formula for checking this logic condition should be like this:
MACD_1 < 0 AND MACD_0 > 0
What we see on the chart is that this condition is not fulfilled for the current bar. Both MACD_1 and MACD_0 are greater than zero. Why do we have a long entry in this bar? The answer is that we shift the signal by one bar due to the Use previous bar value = true condition.
In the above example, the actual crossing is at bar 1 since MACD_2 < 0 AND MACD_1 > 0
but instead rising an entry signal at that, the program shifts the signal one bar ahead and the actual entry is at the current bar (0 marked).
The same signal shift reflects on all indicators with activated Use previous bar value option. For easier recognition of that case, all such indicators on the chart are marked with asterisk (MACD* instead of simply MACD).
As we mentioned earlier, the Use previous bar value option reflects on the backtest result. Using it, the program prevents a very tricky situation when a strategy looks in the future in order to raise a more profitable signal.
Here is the paradox: MACD uses the Close price of the bar. That means that MACD will receive its real and final value exactly at the moment of bar closing. Every earlier MACD value is a temporary one. It most probably will be changed until the bar end since the market price there will be different from the current one. The problem comes from the fact that we have to make the decision for opening a position at the beginning of the bar. (Remember that the entry point of the position is Bar Opening.) We have one temporary MACD value at bar open. If happens that this value is greater than zero and the previous MACD value was lower than zero, we have to enter long and the beginning of the bar according to the strategy logic. That will be OK for the moment but imagine that the market drops during the bar and at the end of the bar MACD has a negative value. In that case, we'll end with a long position open but since the final MACD is lower than zero, the strategy logic will not be fulfilled.
We can think that this case is not a big problem excusing our entry with the fact that the strategy logic was perfectly correct at the moment of entry (at bar Open). The trick comes from the fact that during the backtest, all bars are accomplished and the tester always sees the final value of the indicators. It means that the tester cheats when open a position at the bar beginning using an indicator value from the bar closing. The tester looks to the end of a bar and knowing that price and the indicator conditions, it makes decision to entry or not at much earlier time - at bar opening. Unfortunately, no one can do this in a real live trade. We do not know where the market price will be at the end of the bar. Therefore we must not allow the backtester to do something that we are not able to apply later.
To convince you how destructive such logically incorrect back test can be, I'll show you one example, which you can reproduce with FSB or with a MT expert advisor.
Since Use previous bar value indicator option is automatically controlled by the program by default, you have to switch off that behaviour in case you want to experiment with it. I'll do this also:
Now I'm going to reproduce a looking in the future in a brutal way.
I'll start from a new strategy. (If you want to follow me press Ctrl + N in FSB.)
Now I'll add a simple Moving Average with period of 1 as an “Opening Logic Condition”. Lets the MA is based on Close price. A Moving Average (Close, 1) is actually equal to the bar closing price. Continue in that direction, I'll use the following logic rule - “The Moving Average rises”, which can be paraphrased to “Current bar Close is greater than the previous bar Close.”
Here is the strategy and the backtest balance chart:
Hmm, nothing what we haven't seen before here you'll tell me and you'll be right. But wait for a moment. Notice that FST has set Use previous bar value option of the MA automatically to on. That is default behaviour of the program even when you switched off that control. But doing so, the program grants you a permission to change Use previous bar value on and off manually. So lets return back to the properties of the Moving Average and lets switch off Use previous bar value.
This is what I wanted to tell you from the beginning. The backtest can be really wrong if you do not pay attention on the details.
We see on the chart above that a wrong setting of the Use previous bar value can be very tricky. Some times, it is not so easy to find such a mistake. Fortunately the backtest safe aspect is a core feature of Forex Strategy Builder. The backtesting algorithm and all technical indicators included into the program distribution are made in such way that prevents a user from logical errors. Our goal as authors of FSB was to make it as durable and reliable as possible. That's why Use previous bar value option is automatically controlled by the program and even if you switch it off for an experiment, at the next start of the program it will be activated again.
Another feature of Forex Strategy Builder that aims preventing false understanding of the technical indicators is the True Charts concept. It makes it possible for a user easier orientation of the signals rose by the indicators. Lets show how the previous MACD example looks like with True Chart mode switched on.
We see on that chart that the current MACD value is drown as a horizontal line and it is actually equal to the MACD value from the previous bar closing. True Charts integrate the Use previous bar value idea. We see now that the MACD line (the blue line on the chart) crosses the zero line at the bar, at which we open a position. Another effect is that the final MACD value, which comes at the end of the bar, is plotted not at the middle of the candle but at its right side. (The small crosses represent the indicators final values.)
The logic behind Use previous bar value is not a rocket science. I'm going to show you the rules it follows, so you'll be able to use this principles with all platforms and technical indicators.
We use two facts when deciding whether to use the current or the previous indicator's value for evaluating the logic conditions:
Said with simple words:
There are also cases where we have to make the decision somewhere inside a bar. Such a case is for example when the entry price is an indicator. Here the marker can reach the entry price after the bar open and before its close. Such entries are at a Moving Average, Pivot Points, Bollinger Bands…
In addition, some indicators may use a base price different than Bar Open and Bar close. For example such prices are:
Middle Price = (High + Low) / 2; Typical Price = (High + Low + Close) / 3; Weighted Price = (High + Low + 2 * Close) / 4;
I'll call these prices Intermediate.
To be easier for you, I'll arrange all cases according to the time of decision and the indicator's base price: