Removes, inverts, or randomizes trend in historic price data. Can be set up for removing bias from the parameters, the trades, the indicators, or the whole price curve. Backtesting with detrended, inverted, or randomizied price curves is also a quick "reality check" to verify the validity and robustness of a strategy. For removing trend, the curve or parts of it are "tilted" until the start and end prices have the same value.

          Shuffled EUR/USD price curves


The following flags can be set or combined with '+' or '|':
TRADES Detrend trade results. The trade return is corrected by the average price slope of the current WFO cycle. This removes trend bias from a WFO test while keeping the properties of the price curve.
PRICES Detrend trade results and price functions. The prices are corrected by the average price slope of the current WFO cycle. For detrending indicators and signals based on series generated with price() calls.
CURVE Detrend historical price data on loading. The curve is tilted so that the end and the start of the historical data are at the same level. This also affects the displayed price curve in the chart.
RECIPROCAL Replace prices with their reciprocal values. This it can be used for creating an artifical asset as the reciprocal of an existing forex or crypto pair (f.i. convert BTC/USD to USD/BTC).
INVERT Similar to RECIPROCAL, but keep the price range while inverting the price curve. This reverses all trends in the curve, and can be used for a reality check of a system that is symmetric in long and short positions.
SHUFFLE Randomize the price curve by shuffling the price ticks. Keeps its overall trend from start to end, but removes any short-term trends and correlations between the prices. Used for reality checks.
Randomize the price curve as above, but generate a curve that does not exceed the highest peak or/and the lowest valley of the original price curve. Use this for keeping the original price range. Can be slow.
NOPRICE Do not do not detect gaps or fix outliers on loading. For data files that contain no prices, but other types of data.




Example (see also Detrend.c):

if(is(TRAINMODE)) Detrend = CURVE; // detrend the price curve for training

See also:

mode, WFO, DataSlope, randomize, setf


► latest version online