|
http://support.tsresearchgroup.com/viewtopic.php?p=1568
wavelet less delay
repost here :
jackvg
Guest
Joined: 21 May 2004
Posts: 2
Posted: Tue May 25, 2004 2:17 pm Post subject: Wavelet Transform usage.
--------------------------------------------------------------------------------
First I tried it like a moving ave. crossover and it worked well. Then I tried combining 2 cycles and that was even better. What I would like is to get the phase angle of the cycles and trade based on the phase angles at the max or min. I can post code of the first two if anyone is interested.
Back to top
DT
Developers Team
Joined: 03 Feb 2004
Posts: 188
Posted: Tue May 25, 2004 4:54 pm Post subject: Re: Wavelet Transform usage.
--------------------------------------------------------------------------------
jackvg wrote:
What I would like is to get the phase angle of the cycles and trade based on the phase angles at the max or min.
I guess it is promising approach. I'd use Hilbert Transform to get instantaneous frquencies and amplitudes. THen, I'd trade the wavelet that has maximal absolute amplitude.
Back to top
Steveg
Guest
Joined: 19 Jul 2004
Posts: 2
Posted: Mon Jul 19, 2004 2:57 am Post subject: Accessing Wavelet Dll from Matlab, C++, C#, etc
--------------------------------------------------------------------------------
Hello
I have the wavelet dll and would like to be able to call it from other languages then Tradestation. Matlab, for instance, has a Generic DLL intertface. But it requires the tswvl.h header file to automatically generate a wraper for tswvl.dll. Could you please provide tswvl.h?
Thank you
Steve
Back to top
VladGor
Support Team
Joined: 26 Jan 2004
Posts: 528
Posted: Mon Jul 19, 2004 1:08 pm Post subject:
--------------------------------------------------------------------------------
Dear Steve,
We have product for linking TradeStation with Matlab: TSMATLABLINK.dll
This product is in testing state so if you want you can get beta version of it.
For example calculation of Mean using functions of Matlab looks the following:
EasyLanguage:
{***************************************************************************************
Name: TS.MATLAB.TEST
Analysis Type: Indicator
Used: TSMATLABLINK.dll
Description: Calculated Mean using MATLAB The MathWorks, Inc (http://www.mathworks.com/)
Provided By: Trade Smart Research (c) Copyright 2001 - 2004 www.tsresearchgroup.com
***********************************************************************}
Input: Length(21);
{Declaration of function}
defineDLLFunc: "tsmatlablink.dll", float, "TS_ExecMatlabCmd",lpstr;
if currentbar = 1 then begin
Value1=TS_ExecMatlabCmd("A=[]"); {Call of Matlab forming array}
end else begin
Value1=TS_ExecMatlabCmd("A=[A "+NumToStr(C,4)+"1]"); {Transmiting data and commands to Matlab}
if currentbar>Length+1 then
Value1=TS_ExecMatlabCmd("A(1)=[]");
Value1=TS_ExecMatlabCmd("mean(A)"); {Getting valuea of Mean }
end;
Plot1(Value1, "Value");
Back to top
Steveg
Guest
Joined: 19 Jul 2004
Posts: 2
Posted: Mon Jul 19, 2004 1:52 pm Post subject:
--------------------------------------------------------------------------------
Thank you, that looks very interesting! Yes!, I would like to get a beta copy of TSMATLABLINK.dll
I still would like the Wavelet transform header file, tswvl.h, to be able to directly call your Wavelet routines from any program that can call dll's
Thanks again
Steve
Back to top
VladGor
Support Team
Joined: 26 Jan 2004
Posts: 528
Posted: Tue Jul 20, 2004 12:35 pm Post subject:
--------------------------------------------------------------------------------
We replied you directly through mail.
Back to top
alexsf
Guest
Joined: 17 Jan 2005
Posts: 1
Posted: Tue Jan 18, 2005 6:53 am Post subject: Re: Accessing Wavelet Dll from Matlab, C++, C#, etc
--------------------------------------------------------------------------------
Hi All,
I am wondering if someone has actually seen an improvement over standard MAs after using wavelets in real life trading.
I looked through TSG ad doc about Wavelets (posted on the homepage):
Example 9, crossover system: Percent Profitable = 58%, Avg.Win/Avg.Loss=2.339, drawdown given in abs units (meaningless).
Not bad, but why is it much better than the std Xover system?
The authors show Example 10, where MAs (same lookback as wavelets) purportedly works much worse:
%profitable=39%, Win/Loss=2.125, yet CAR=230%. Looks much worse than Ex.9 with CAR=882%, but what if one uses EMAs or DEMAs, or
better still Tillson's T3, NOT handicapped simple MAs?
Me thinks it will be the similar - could you please check this and post for a number of different securities (Russian, NYSE, Nasdaq) to prove the point?
Adequate comparison should probably involve two of these methods _optimized_ on some market and then used on a bunch of OTHER markets to see which is really better. The present comparison does not tell me much pro or contra, frankly, not very convincing.
This would be very interesting (and educational) indeed,
Cheers -
[quote="Steveg"]Hello
I have the wavelet dll and would like to be able to call it from other languages then Tradestation. Matlab, for instance, has a Generic DLL intertface. But it requires the tswvl.h header file to automatically generate a wraper for tswvl.dll. Could you please provide tswvl.h?
Thank you
Steve[/quote]
_________________
-alex
Back to top
DT
Developers Team
Joined: 03 Feb 2004
Posts: 188
Posted: Wed Jan 19, 2005 2:35 pm Post subject: Re: Accessing Wavelet Dll from Matlab, C++, C#, etc
--------------------------------------------------------------------------------
alexsf wrote:
I looked through TSG ad doc about Wavelets:
... why is it much better than the std Xover system?
The authors show Example 10, where MAs (same lookback as wavelets) purportedly works much worse:
%profitable=39%, Win/Loss=2.125, yet CAR=230%. Looks much worse than Ex.9 with CAR=882%, but what if one uses EMAs or DEMAs, or
better still Tillson's T3, NOT handicapped simple MAs?
Wavelet based MA system is better because of its pre-filtering rather then less delay. It has less false crissovers. To us, the most fruitful feature of wavelet-like decompositions is their multiscality. We are digging there currently.
Regards
Back to top
bearwatch
Guest
Joined: 22 May 2006
Posts: 30
Posted: Tue May 23, 2006 12:21 pm Post subject:
--------------------------------------------------------------------------------
Is there a list of indicators that the Wavelet Transform work best with so I can try it for myself? It's an interesting concept and would like to test them out. Another question, if I would like to use it in a strategy, how would I modify to create signals for entries and exits? Is this already available? Thanks.
Back to top
DT
Developers Team
Joined: 03 Feb 2004
Posts: 188
Posted: Tue May 23, 2006 12:31 pm Post subject:
--------------------------------------------------------------------------------
these are some examples for older TS2000i
EasyLanguage:
{************************************************************************************************************
Non-decimated Haar Wavelet Slope signal
Copyright (c) Trade Smart Research Group 2002
Notes: The math is based on Multiresolution Analysis of Time Series
www.multiresolutions.com
*************************************************************************************************************}
Inputs: EntryScale(6), ExitScale(5);
vars: Lookback(0), Scales(0), EntryWL(0), ExitWL(0), Count(0);
Array: ArrayPrice[511](0);
defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float;
defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int;
Scales = maxlist(EntryScale, ExitScale);
lookback = power(2, Scales);
for count = 0 to lookback-1 begin
ArrayPrice[count] = Close[count];
end;
Value1 = RUNWVL(&ArrayPrice[0],Scales, 0);
EntryWL = GetAllValues(3,EntryScale);
ExitWL = GetAllValues(3,ExitScale);
Condition1 = EntryWL > EntryWL[1];
Condition2 = ExitWL > ExitWL[1];
If Condition1 = True and Condition2 = True Then
Buy("Slope.LE") at close;
If Condition1 = False and Condition2 = False Then
Sell("Slope.SE") at close;
If Condition2 = False Then
ExitLong("Slope.LX") at close;
If Condition2 = True Then
ExitShort("Slope.SX") at close;
===============================================
EasyLanguage:
{************************************************************************************************************
Non-decimated Haar Wavelet Trend Nowcast Signal
Copyright (c) Trade Smart Research Group 2003
Notes: Wavelets are computed on swing extrema rather then on price series.
The math is based on Multiresolution Analysis of Time Series
www.multiresolutions.com
*************************************************************************************************************}
Inputs: Scale(5), NSigma(3);
vars: Wavelet(0), Sigma(0), Trend(0), countarray(0), num(1);
Array: ArrayPrice[511](0);
defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float;
defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int;
vars: Swing(0), DnSwing(False), UpSwing(False), DnTrend(False), UpTrend(False),
ContrH(H), ContrL(L), SwingH(H), SwingL(L), count(0);
if barnumber = 1 then countarray = 0;
{%%%%%%%%%%%%%%%%%%%%%% SWING CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
{ DT definition }
DnSwing = low < low[1];
UpSwing = high > high[1];
if UpSwing = True and high >= ContrH then Swing = 1;
if DnSwing = True and low <= ContrL then Swing = -1;
if Swing >= 0 and high > SwingH then begin
SwingH = high;
ContrL = low;
ContrH = high;
end;
if Swing <=0 and low < SwingL then begin
SwingL = low;
ContrH = high;
ContrL = low;
end;
if Swing >= 0 and high <= high[1] and low > low[1] then ContrL = low;
if Swing <= 0 and high < high[1] and low >= low[1] then ContrH = high;
if Swing = 1 and Swing[1] <> 1 then begin
For count = 255 downto 1 begin
ArrayPrice[count] = ArrayPrice[count - 1];
end;
ArrayPrice[0] = SwingL;
SwingL = 999999;
ContrH = high;
countarray = countarray + 1;
end;
if Swing = -1 and Swing[1] <> -1 then begin
For count = 255 downto 1 begin
ArrayPrice[count] = ArrayPrice[count - 1];
end;
ArrayPrice[0] = SwingL;
SwingH = 0;
ContrL = low;
countarray = countarray + 1;
end;
{*************** Wavelet computation *****************}
if countarray >= Power(2, Scale) then begin
Value1 = RUNWVL(&ArrayPrice[0], 8, NSigma);
Wavelet = GetAllValues(1, Scale);
Sigma = GetAllValues(2, Scale);
{************* Signals ******************************}
if Wavelet > NSigma * Sigma {and absvalue(Wavelet[1]) < NSigma * Sigma[1]} then buy("NCast.LE") num contracts at close;
{New upward detection}
if Wavelet < - NSigma * Sigma {and absvalue(Wavelet[1]) < NSigma * Sigma[1]} then sell("NCast.SE") num contracts at close;
{New downward detection}
if absvalue(Wavelet) < NSigma * Sigma and absvalue(Wavelet[1]) > NSigma * Sigma[1] then begin
{End of significant structure}
if marketposition = 1 then ExitLong("NCast.LX") at close;
if marketposition = -1 then ExitShort("NCast.SX") at close;
end;
end;
===============================================
EasyLanguage:
{************************************************************************************************************
Non-decimated Haar Wavelet Trend Nowcast 2 Signal
Copyright (c) Trade Smart Research Group 2002
Notes: The math is based on Multiresolution Analysis of Time Series
www.multiresolutions.com
*************************************************************************************************************}
Inputs: Scale(5), NSigma(3);
vars: count(0), num(1);
Array: ArrayPrice[511](0);
defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float;
defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int;
for count = 0 to power(2, Scale) - 1 begin
ArrayPrice[count] = MedianPrice[count];
end;
Value1 = RUNWVL(&ArrayPrice[0], Scale + 1, NSigma); {residual}
value2 = GetAllValues(1, Scale); {Wavelet(scale)}
value3 = GetAllValues(2, Scale); {Sigma}
value4 = 0; {Wavelet sum}
For count = 1 to Scale - 1 begin
value4 = value4 + GetAllValues(1, count);
end;
value5 = value1 + value4; {Residual + Wavelet Sum - Wavelet(scale)}
buy("NCast.LE") num contracts at value5 + Nsigma * value3 stop;
sell("NCast.SE") num contracts at value5 - Nsigma * value3 stop;
ExitLong("NCast.LX") at value5 stop;
ExitShort("NCast.SX") at value5 stop;
{SetExitOnClose;}
===============================================
EasyLanguage:
{************************************************************************************************************
Non-decimated Haar Wavelet Trend Nowcast Signal
Copyright (c) Trade Smart Research Group 2002
Notes: The math is based on Multiresolution Analysis of Time Series
www.multiresolutions.com
*************************************************************************************************************}
Inputs: NSigma(3);
vars: count(0), num(1);
Array: ArrayPrice[511](0), Wavelet[9](0), Sigma[9](0);
defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float;
defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int;
for count = 0 to 511 begin
ArrayPrice[count] = MedianPrice[count];
end;
Value1 = RUNWVL(&ArrayPrice[0], 9, NSigma);
for count = 3 to 9 begin
Wavelet[count] = GetAllValues(1,count);
Sigma[count] = GetAllValues(2,count);
end;
if Wavelet[2] > NSigma * Sigma[2] and Wavelet[2][1] < NSigma * Sigma[2][1] then
{upward detection}
buy ("2.LE") num contracts at close;
if Wavelet[2] < - NSigma * Sigma[2] and Wavelet[2][1] > - NSigma * Sigma[2][1] then
{downward detection}
sell("2.SE") num contracts at close;
if Wavelet[2] < NSigma * Sigma[2] and Wavelet[2][1] > NSigma * Sigma[2][1] then
{End of positive structure}
ExitLong from entry("2.LE") at close;
if Wavelet[2] > - NSigma * Sigma[2] and Wavelet[2][1] < - NSigma * Sigma[2][1] then
{End of negative structure}
ExitShort from entry("2.SE") at close;
if Wavelet[3] > NSigma * Sigma[3] and Wavelet[3][1] < NSigma * Sigma[3][1] then
{upward detection}
buy ("3.LE") num contracts at close;
if Wavelet[3] < - NSigma * Sigma[3] and Wavelet[3][1] > - NSigma * Sigma[3][1] then
{downward detection}
sell("3.SE") num contracts at close;
if Wavelet[4] > NSigma * Sigma[4] and Wavelet[4][1] < NSigma * Sigma[4][1] then
{upward detection}
buy ("4.LE") num contracts at close;
if Wavelet[4] < - NSigma * Sigma[4] and Wavelet[4][1] > - NSigma * Sigma[4][1] then
{downward detection}
sell("4.SE") num contracts at close;
if Wavelet[5] > NSigma * Sigma[5] and Wavelet[5][1] < NSigma * Sigma[5][1] then
{upward detection}
buy ("5.LE") num contracts at close;
if Wavelet[5] < - NSigma * Sigma[5] and Wavelet[5][1] > - NSigma * Sigma[5][1] then
{downward detection}
sell("5.SE") num contracts at close;
if Wavelet[6] > NSigma * Sigma[6] and Wavelet[6][1] < NSigma * Sigma[6][1] then
{upward detection}
buy ("6.LE") num contracts at close;
if Wavelet[6] < - NSigma * Sigma[6] and Wavelet[6][1] > - NSigma * Sigma[6][1] then
{downward detection}
sell("6.SE") num contracts at close;
{*** exits ****}
{ if Wavelet[3] < NSigma * Sigma[3] and Wavelet[3][1] > NSigma * Sigma[3][1] then
{End of positive structure}
ExitLong from entry("3.LE") at close;
if Wavelet[3] > - NSigma * Sigma[3] and Wavelet[3][1] < - NSigma * Sigma[3][1] then
{End of negative structure}
ExitShort from entry("3.SE") at close;
if Wavelet[4] < NSigma * Sigma[4] and Wavelet[4][1] > NSigma * Sigma[4][1] then
{End of positive structure}
ExitLong from entry("4.LE") at close;
if Wavelet[4] > - NSigma * Sigma[4] and Wavelet[4][1] < - NSigma * Sigma[4][1] then
{End of negative structure}
ExitShort from entry("4.SE") at close;
if Wavelet[5] < NSigma * Sigma[5] and Wavelet[5][1] > NSigma * Sigma[5][1] then
{End of positive structure}
ExitLong from entry("5.LE") at close;
if Wavelet[5] > - NSigma * Sigma[5] and Wavelet[5][1] < - NSigma * Sigma[5][1] then
{End of negative structure}
ExitShort from entry("5.SE") at close;
if Wavelet[6] < NSigma * Sigma[6] and Wavelet[6][1] > NSigma * Sigma[6][1] then
{End of positive structure}
ExitLong from entry("6.LE") at close;
if Wavelet[6] > - NSigma * Sigma[6] and Wavelet[6][1] < - NSigma * Sigma[6][1] then
{End of negative structure}
ExitShort from entry("6.SE") at close;} |
|