Hi, That is not quite what Aronson was describing. Aronson was describing the removal of trend from data covering a fixed period such that backtested results on that period could be evaluated without the effects of market trend.
To do so, the log daily mean of the *entire period* is subtracted from each log daily change in that period (i.e. the same value is subtracted from the first bar as is subtracted from the last bar and every bar in between). The end result is that the mean of the adjusted values for that period will equal zero. In other words no presence of trend at all. As such, any gains produced by the strategy will be attributable only to the strategy itself, and not to overall market trend. If I understand your code correctly; You are subtracting a different mean from each bar, based on the data that came before it, rather than based on the range under study. For any range, the mean of the adjusted values produced by your formula will not be zero and thus is not what Aronson was doing. However, what you have produced may prove to be a handy indicator. Thanks for the contribution. Mike --- In [email protected], "thomasdrewyallop" <[EMAIL PROTECTED]> wrote: > > This may be what you are looking for: > > //gives each bar's previous Close > priorClose = Ref(Close, -1); > > // Reset 1st value of CLOSE and prior CLOSE > priorClose[0] = 0; > Close[0] = 0; > > priceChange = Close / priorClose; > > //gives each bar's price-change logarithm, corrected for NaN and > Infinite > logPC = log(priceChange); > logPC = IIf(IsNull(logPC) OR NOT(IsFinite(logPC)), 0, logPC); > > //gives cumulative logarithm for each bar > CumLogs = Cum(logPC); > > //gives average cumulative logarithm for each bar > meanLog = CumLogs / BarIndex(); > > //gives each bar's detrended close > detrendedClose = Close - meanLog; > > // plots the close with solid line > Plot(detrendedClose,"Detrended Close",colorBlack,styleLine); > Plot(Close, "Close", colorRed, styleLine); > > // debug values > printf("close0=" + WriteVal(Close[0]) + "\n"); > printf("priorclose[0]" + WriteVal(priorclose[0]) + "\n"); > printf("priorClose=" + WriteVal(priorClose) + "\n"); > printf("Barindex=" + WriteVal(BarIndex()) + "\n"); > printf("Close=" + WriteVal(Close) + "\n"); > printf("pricechange=" + WriteVal(pricechange) + "\n"); > printf("logpc=" + WriteVal(logpc) + "\n"); > printf("cumlogs=" + WriteVal(Cumlogs, 1.4) + "\n"); > printf("meanlog=" + WriteVal(meanlog, 1.4) + "\n"); > printf("detrendedclose=" + WriteVal(detrendedclose) + "\n"); >
