Overview: Wavelet Trend Nowcast Signal
Example 5. . The signal that opens positions if trend is identified on the given scale, and closing them if the end of trend is fond.

| eSignal Formula Script: | /******************************************************** Name: TSE.Wavelet.Nowcast Analysis Type: Strategies Description: Non-decimated Haar Wavelet Trend Nowcast Signal Used: tsewvl.dll Provided By: Trade Smart Research (c) Copyright 2001 - 2004 www.tsresearch.com ********************************************************/ var c,v,Wavelet,Sigma,Trend, num,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 Trend Nowcast Strategies"); setCursorLabelName("Nowcast", 0); ArrayPrice = new Array(256); var fp1 = new FunctionParameter("Scales", FunctionParameter.NUMBER); fp1.setLowerLimit(1); fp1.setUpperLimit(8); fp1.setDefault(5); var fp2 = new FunctionParameter("NSigma", FunctionParameter.NUMBER); fp2.setLowerLimit(1); fp2.setUpperLimit(4); fp2.setDefault(3); } function main(Scales,NSigma) { if (Scales==null) Scales=5; if (NSigma==null) NSigma=3; lookback=256; aSource=getValue("Close",0,-lookback); /* filling array */ nBarIndex = getNumBars()+getCurrentBarIndex(); if (nBarIndex >lookback) { for (x=0; x<lookback; x++) { ArrayPrice[x] = aSource[x]; } /* calling functoin in dll */ v = d.call("runwvl",ArrayPrice,8,NSigma); Wavelet =d.call("getallvalues",1,Scales); Sigma =d.call("getallvalues",2,Scales); /* determinig trend */ if (Wavelet > (NSigma * Sigma)) { Trend = 1 } else { if (Wavelet < (- NSigma * Sigma)) { Trend = -1 } else { Trend = 0 } } /* Strategy Actions Entry to position and exit form it */ if (Trend == 1) { if(!Strategy.isLong()) { Strategy.doLong("NCast.LE",Strategy.CLOSE,Strategy.THISBAR) } } if (Trend == -1) { if(!Strategy.isShort()) { Strategy.doShort("NCast.SE",Strategy.CLOSE,Strategy.THISBAR) } } if ((Trend==0) && (Strategy.isInTrade()==true)) { if (Strategy.isLong()==true) { Strategy.doSell("NCast.LX",Strategy.CLOSE,Strategy.THISBAR) }; if (Strategy.isShort()==true) { Strategy.doCover("NCast.SX",Strategy.CLOSE,Strategy.THISBAR) }; } if(Strategy.isLong()) { setBarBgColor(Color.green); } else if(Strategy.isShort()) { setBarBgColor(Color.red); } } else { v=0 } return v; } |
These elementary examples evidently show that modern computer methods can improve an arsenal of technical analytics.
|