/******************************************************** Name: TSE.Wavelet.Denoised.Residual Analysis Type: Indicator Description: Non-decimated Haar Wavelet Denoised & Residual Indicator Used: tsewvl.dll Provided By: Trade Smart Research (c) Copyright 2001 - 2004 www.tsresearch.com *******************************************************/ var c,v1,v2,v3,lookback; /* Defining DLL */ var d = new DLL("tsewvl.dll"); /* Functions Declaration */ d.addFunction("runwvl", DLL.FLOAT, DLL.STDCALL,"RUNWVL", DLL.FLOATARRAY,DLL.INT,DLL.FLOAT); d.addFunction("getallvalues", DLL.FLOAT, DLL.STDCALL,"GETALLVALUES", DLL.INT,DLL.INT); /* Preparing parameters and array*/ function preMain() { setPriceStudy(true); setStudyTitle("Wavelet Denoised & Residual"); setCursorLabelName("Denoised", 0); setDefaultBarStyle(PS_SOLID, 0); setDefaultBarFgColor(Color.red, 0); setDefaultBarFgColor(Color.blue, 1); setDefaultBarThickness(1, 0); setPlotType(PLOTTYPE_LINE, 0); ArrayPrice = new Array(512); var fp1 = new FunctionParameter("Scales", FunctionParameter.NUMBER); fp1.setLowerLimit(1); fp1.setUpperLimit(8); fp1.setDefault(6); var fp2 = new FunctionParameter("NSigma", FunctionParameter.NUMBER); fp2.setLowerLimit(1); fp2.setUpperLimit(4); fp2.setDefault(2) } function main(Scales,NSigma) { if (NSigma==null) NSigma=2; if (Scales==null) Scales=6; /* calculation of quantity of elements of a Array */ lookback=Math.pow(2,Scales); /* determinig source */ aSource=getValue("Close",0,-lookback); /* filling array */ nBarIndex = getNumBars()+getCurrentBarIndex(); if (nBarIndex >lookback) { for (x=0; x<lookback; x++) { ArrayPrice[x] = aSource[x]; } /* the smoothed series */ v1 = d.call("runwvl",ArrayPrice,Scales,NSigma); v2 = Scales + 1; v3 = d.call("getallvalues",3,v2); } else { v=0 } return new Array (v1,v3); } |