Overview: Wavelet Trend Detection ShowMe
Example 5. ShowMe that identifies the trend on each bar on all given scales.

To apply the study to the plot, it is necessary to start TS_Wvl Trend Nowcast from menu ShowMe, to press button Expert Commentary and to click the mouse on the required bar. After that the comment window will appear. The result is shown in the figure above. The family of low-frequency filters (Example 3) and wavelet coefficients (Example 4) is applied to the plot too. It is interesting to notice that in the points where trend is not identified on several scales, the appropriate low-frequency filters coincide, but are not crossed, that allows avoid false signals whichcrossing moving averages , for example, will give there. The concurrence of filters can be treated as the indicator of the breakout mode and the avoiding to use counter trend methods.
| EasyLanguage: | {******************************************************** Non-decimated Haar Wavelet Trend Detection ShowMe Copyright (c) Trade Smart Research Group 2002 Notes: The math is based on Multiresolution Analysis of Time Series www.multiresolutions.com ********************************************************} Inputs: Price(Close), {a price series} NSigma(2); {threshold value signal / noise} vars: Lookback(0), AllText(""), count(0); {definition of variables} Arrays: Sigma[10](0), Wavelet[10](0), Comment[10](""); {definition of Array} Array: ArrayPrice[511](0); defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float; defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int; for count = 0 to 511 begin {the task of elements of Array} ArrayPrice[count] = Price[count]; end; Value1 = RUNWVL(&ArrayPrice[0], 9, NSigma); {call dll function} AllText = ""; for count = 1 to 9 begin Wavelet[count] = GetAllValues(1,count); Sigma[count] = GetAllValues(2,count); if absvalue(Wavelet[count]) < NSigma * Sigma[count] then Comment[count] = "No detection"; if Wavelet[count] > NSigma * Sigma[count] and absvalue(Wavelet[count][1]) < NSigma * Sigma[count][1] then Comment[count] = "New upward detection" + " SNR = " + NumToStr(AbsValue(iff(Sigma[count] >0, Wavelet[count] / Sigma[count], 1)), 2); if Wavelet[count] < - NSigma * Sigma[count] and absvalue(Wavelet[count][1]) < NSigma * Sigma[count][1] then Comment[count] = "New downward detection" + " SNR = " + NumToStr(AbsValue(iff(Sigma[count] >0, Wavelet[count] / Sigma[count], 1)), 2); if Wavelet[count] > NSigma * Sigma[count] and Wavelet[count][1] < - NSigma * Sigma[count][1] then Comment[count] = "Upward reversal" + " SNR = " + NumToStr(AbsValue(iff(Sigma[count] >0, Wavelet[count] / Sigma[count], 1)), 2); if Wavelet[count] < - NSigma * Sigma[count] and Wavelet[count][1] > NSigma * Sigma[count][1] then Comment[count] = "Downward reversal" + " SNR = " + NumToStr(AbsValue(iff(Sigma[count] >0, Wavelet[count] / Sigma[count], 1)), 2); if Wavelet[count] > NSigma * Sigma[count] and absvalue(Wavelet[count][1]) > NSigma * Sigma[count][1] then Comment[count] = "Positive significant structure"; if Wavelet[count] < - NSigma * Sigma[count] and absvalue(Wavelet[count][1]) > NSigma * Sigma[count][1] then Comment[count] = "Negative significant structure"; if absvalue(Wavelet[count]) < NSigma * Sigma[count] and absvalue(Wavelet[count][1]) > NSigma * Sigma[count][1] then Comment[count] = "End of significant structure"; AllText = AllText + "SCALE " + NumToStr(count, 0) + " " + Comment[count] + NewLine; end; if atCommentaryBar then begin CommentaryCL(AllText); value1 = Text_New(Date, Time, L, ""); end;
|
|