by Bill Brower on May 30, 2016 | Categories: Uncategorized |
The MaxBarsBack (MBB) setting is usually set to automatically detect the required lookback for indicators but strategies are by default set to a lookback of 50. Before you become proficient at TS you are bound to be baffled by the issues of MBB.
Here is one example. You write two pieces of code; one is a system and the other is an indicator. They both use an exponential moving average of 50 bars. When you place them both on the same chart of data, you notice at the beginning of the chart the system is taking trades that appear to be inconsistent with the indicator. The problem is the MBB. Since the exponential moving average indicator only requires a MBB of 2, it begins its computations and displaying results on the second bar of the chart. The system begins computing on the 51st bar of the chart because the default lookback is 50.
The XMA algorithm in the strategy may take as many as 100 bars after the first 50 lookback bars to stabilize and so near the beginning of the chart, it will not be in synchronization with the XMA indicator which began plotting on the 2nd bar of the chart. By the time the strategy is computing the XMA for the first time, the indicator has already been computing for 50 bars. That means the indicator computations do not match the strategy computations until about bar 150. You can rectify this by manually setting the indicator MBB to 50, or if possible, set the MBB of the strategy to 2. Then the indicator and the system will both have the same starting point and generate the same expected result. The latter solution is still somewhat flawed because it is using XMA values that have not settled down yet so it would be best if you then required a filter to block trades until after the 100th bar of the chart. That would look something like this:
If currentbar > 100 then begin
…your entry signals go here…