linchiyh 發表於 10-11-2 15:29

程式交易必讀的好書

不看是你的損失,閒閒沒事加減看 {:4_106:}




1.Rocket science for traders: digital signal processing applications 作者:John F. Ehlers
2.MESA and Trading Market Cycles: Forecasting and Trading Strategies from the ... 作者:John F. Ehlers3.Cybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading

TrendRover 發表於 10-11-2 16:14

沒dsp 背景想看懂:
    請回去念 電子 系 !!
   squelch ,IIR FIR etc .
   
    有人用過 wavelet 或 polyphase filter 吗 ? 這樣就進入 advance DSP
的領域 .
multichart 6.0內有 ts.wvl.crossover 等 function
是不是 小波分析(wavelet analysis)勝過 MESA or DFT 就要看些新papers 才知.

michigan 發表於 10-11-2 16:33

本帖最後由 michigan 於 10-11-2 04:37 PM 編輯

...除了Amazon可看簡介...不知道大台北那邊有機會可看看新的原文TRADING的書?........
只想看看...不大想買...那些書很多可能實務上都沒什用的.....{:4_189:}

TrendRover 發表於 10-11-2 16:52

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="); {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 -

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
_________________
-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(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 = Close;
end;
Value1 = RUNWVL(&ArrayPrice,Scales, 0);
EntryWL = GetAllValues(3,EntryScale);
ExitWL = GetAllValues(3,ExitScale);

Condition1 = EntryWL > EntryWL;
Condition2 = ExitWL > ExitWL;

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(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;
UpSwing = high > high;

if UpSwing = True and high >= ContrH then Swing = 1;   
if DnSwing = True and low <= ContrL thenSwing = -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 and low > low then ContrL = low;
if Swing <= 0 and high < high and low >= low then ContrH = high;

if Swing = 1 and Swing <> 1 then begin
    For count = 255 downto 1 begin
      ArrayPrice = ArrayPrice;
    end;
    ArrayPrice = SwingL;
    SwingL = 999999;
    ContrH = high;
    countarray = countarray + 1;
end;   

if Swing = -1 and Swing <> -1 then begin
    For count = 255 downto 1 begin
      ArrayPrice = ArrayPrice;
    end;
    ArrayPrice = SwingL;
    SwingH = 0;
    ContrL = low;
    countarray = countarray + 1;
end;

{*************** Wavelet computation *****************}

if countarray >= Power(2, Scale) then begin

    Value1 = RUNWVL(&ArrayPrice, 8, NSigma);
    Wavelet = GetAllValues(1, Scale);
    Sigma = GetAllValues(2, Scale);

{************* Signals ******************************}
         
    if Wavelet > NSigma * Sigma {and absvalue(Wavelet) < NSigma * Sigma} then buy("NCast.LE") num contracts at close;
      {New upward detection}
    if Wavelet < - NSigma * Sigma {and absvalue(Wavelet) < NSigma * Sigma} then sell("NCast.SE") num contracts at close;
      {New downward detection}
    if absvalue(Wavelet) < NSigma * Sigma and absvalue(Wavelet) > NSigma * Sigma 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(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 = MedianPrice;
end;

Value1 = RUNWVL(&ArrayPrice, 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(0), Wavelet(0), Sigma(0);
defineDLLFunc: "tswvl.DLL", FLOAT, "RUNWVL",LPFLOAT,int,float;
defineDLLFunc: "tswvl.DLL", FLOAT, "GETALLVALUES",int,int;

for count = 0 to 511 begin
    ArrayPrice = MedianPrice;
end;
Value1 = RUNWVL(&ArrayPrice, 9, NSigma);
for count = 3 to 9 begin
    Wavelet = GetAllValues(1,count);
    Sigma = GetAllValues(2,count);
end;

    if Wavelet > NSigma * Sigma and Wavelet < NSigma * Sigma then
      {upward detection}
      buy ("2.LE") num contracts at close;
    if Wavelet < - NSigma * Sigma and Wavelet > - NSigma * Sigma then
      {downward detection}
      sell("2.SE") num contracts at close;
    if Wavelet < NSigma * Sigma and Wavelet > NSigma * Sigma then
      {End of positive structure}
      ExitLong from entry("2.LE") at close;
    if Wavelet > - NSigma * Sigma and Wavelet < - NSigma * Sigma then
      {End of negative structure}         
      ExitShort from entry("2.SE") at close;

    if Wavelet > NSigma * Sigma and Wavelet < NSigma * Sigma then
      {upward detection}
      buy ("3.LE") num contracts at close;
    if Wavelet < - NSigma * Sigma and Wavelet > - NSigma * Sigma then
      {downward detection}
      sell("3.SE") num contracts at close;
   

    if Wavelet > NSigma * Sigma and Wavelet < NSigma * Sigma then
      {upward detection}
      buy ("4.LE") num contracts at close;
    if Wavelet < - NSigma * Sigma and Wavelet > - NSigma * Sigma then
      {downward detection}
      sell("4.SE") num contracts at close;


    if Wavelet > NSigma * Sigma and Wavelet < NSigma * Sigma then
      {upward detection}
      buy ("5.LE") num contracts at close;
    if Wavelet < - NSigma * Sigma and Wavelet > - NSigma * Sigma then
      {downward detection}
      sell("5.SE") num contracts at close;
   

    if Wavelet > NSigma * Sigma and Wavelet < NSigma * Sigma then
      {upward detection}
      buy ("6.LE") num contracts at close;
    if Wavelet < - NSigma * Sigma and Wavelet > - NSigma * Sigma then
      {downward detection}
      sell("6.SE") num contracts at close;

{*** exits ****}
{    if Wavelet < NSigma * Sigma and Wavelet > NSigma * Sigma then
      {End of positive structure}
      ExitLong from entry("3.LE") at close;
    if Wavelet > - NSigma * Sigma and Wavelet < - NSigma * Sigma then
      {End of negative structure}         
      ExitShort from entry("3.SE") at close;

    if Wavelet < NSigma * Sigma and Wavelet > NSigma * Sigma then
      {End of positive structure}
      ExitLong from entry("4.LE") at close;
    if Wavelet > - NSigma * Sigma and Wavelet < - NSigma * Sigma then
      {End of negative structure}         
      ExitShort from entry("4.SE") at close;

    if Wavelet < NSigma * Sigma and Wavelet > NSigma * Sigma then
      {End of positive structure}
      ExitLong from entry("5.LE") at close;
    if Wavelet > - NSigma * Sigma and Wavelet < - NSigma * Sigma then
      {End of negative structure}         
      ExitShort from entry("5.SE") at close;

    if Wavelet < NSigma * Sigma and Wavelet > NSigma * Sigma then
      {End of positive structure}
      ExitLong from entry("6.LE") at close;
    if Wavelet > - NSigma * Sigma and Wavelet < - NSigma * Sigma then
      {End of negative structure}         
      ExitShort from entry("6.SE") at close;}

TrendRover 發表於 10-11-2 17:03

hibert transform filter :
http://en.wikipedia.org/wiki/Hilbert_transform

TrendRover 發表於 10-11-2 17:07

我想大家都有用過 2 MA crossover system 作backtest :
   越快的 whipsaw 越多false signal .
慢的 MA whipsaw少但 delay 大 .
   wavelet 可能解的 delay較少嗎?
沒 tswvl.dll沒得run .

TrendRover 發表於 10-11-2 17:16

http://trader.online.pl/ELZ/t-i-Hilbert_Transform.html



repost here:


Hilbert Transform by John Ehlers

In my first article, using the Hilbert Transform, I showed how the technique could be used for measuring the cyclic content in prices at any given bar on your chart. This, in turn, I used to create an indicator showing you what the cyclic content was and, inferentially, whether you were in a cycle or trending pricing mode. I also included a signal-to-noise ratio computation so you could estimate whether there existed enough signal in the pricing activity to justify trading on the cycle content. Since the article was published, I've come up with a simpler expression for achieving the same result and with slightly less delay.
The revised TradeStation code is:



Typ : Indicator, Name : Hilbert Transform
Inputs: Price((H+L)/2);

Vars: InPhase(0),
Quadrature(0);

If CurrentBar > 5 then begin

Value1 = Price - Price;
Value2 =Value1;
Value3 =.75*(Value1 - Value1) + .25*(Value1 - Value1);
InPhase = .33*Value2 + .67*InPhase;
Quadrature = .2*Value3 + .8*Quadrature;

Plot1(Inphase, "I");
Plot2(Quadrature, "Q");

end;


我覺得 長度調整後 coefficient 要重算 .

TrendRover 發表於 10-11-2 17:19

hilbert period and hilbert channel :

http://trader.online.pl/ELZ/t-i-Hilbert_Channel_Indicator.html

TrendRover 發表於 10-11-2 17:24

John Ehler 有一www site 放所有的 powerpoint files included all filters introduce,
沒買書也可看得到 !!

linchiyh 發表於 10-11-2 18:03

Hilbert sin wave 就很好用了

linchiyh 發表於 10-11-2 18:05

書上也介紹很多Zero lag filter
應該很夠用的說 {:4_107:}

linchiyh 發表於 10-11-2 18:16

最好玩的應該是EMA可以當個系統做補償,學工程的應該覺得很有趣吧

linchiyh 發表於 10-11-2 18:38

回復 6# TrendRover

小弟也曾思考這個問題,發現這些數學工具可能可以解決某些現象,但也產生某些問題(這個問題困擾我近2年,難怪聖杯這麼難搞 {:4_154:})


讀了數套理論,發現都在說類似的事物
所以目前我是反向思考



由線圖的現象,以數學為工具解之
發現其實並不需要非常複雜的數學
當然學得越多,表示手上的工具就越多
解決問題的能力就越強


有人說,這麼複雜的數學真的有用嗎
回測顯示,某些市場還真吃這一套呢

一覽眾山小 發表於 10-11-2 23:26

全世界最有錢的職業應該是數學家跟程式工程師

linchiyh 發表於 10-11-3 08:14

介紹臺灣之光
1998年 中研院 黃院士的理論

Hilbert Huang Transferm

http://www.ancad.com.tw/presentation%20files/VisualSignal/%E4%B8%80%E8%88%AC%E6%80%A7%E4%BB%8B%E7%B4%B9/HHT.pdf

有沒有用自行參考 {:4_93:}
頁: [1] 2
查看完整版本: 程式交易必讀的好書