I finally understand the code for the derivative of a signal in 
PriceVelocity.java, etc.
 
In essence  (using control system terminology):
       fast = Kfast * price + (1-Kfast)*fast_previous               where 
Kfast = 2/(fast_period+1)
 
This is the basic equation of a low pass filter, represented in Laplace 
transform as:   T_fast(s) = 1/( tau_fast * 1 +1)
 
(I dint know an EMA was a low pass filter, learned something new).
 
As a result, the velocity (or derivative) is calculated as the difference 
between two low pass filters:   
          1/(tau_slow*s+1) - 1/(tau_fast*s+1)  =  s  * (tau_slow - 
tau_fast) / ((tau_slow*s +1)*(tau_slow*s +1))
 
Note that:  s is the derivative,  1/ ((tau_slow*s +1)*(tau_slow*s +1)) is a 
unity gain filter, and  (tau_slow - tau_fast) is a scaling factor.
 
The problem I see  is that everytime a period is selected the gain on the 
velocity changes, forcing a change in a scale eslewhere. In order to make 
the velocity have the SAME gain all the time (that is, consistently be a 
velocity), one would need to divide value by (tau_slow - tau_fast)
 
It probably does not change trading results after parameters have been 
chosen, but it would decouple the period selection (the filtering action) 
from the scale on the velocity, probably making for a more robust 
optimization.
 
Given that a tiem constant is approximately tau_fast = 
dt*(fastPeriod+1)/2   where dt = 1 second, then the gain 
(tau_slow-tau_fast) = dt/2*(slowPeriod-FastPeriod)
 
I would try implementing an alternate price velocity indicator:
   value = (fast-slow) *2 / (slowPeriod-fastPeriod)                         
to see if it makes any difference.
 
 
Another alternaltive is to note that   1 - 1/(tau*s+1)  =  s * tau 
/(tau*s+1)    or that the derivative equals the price minus a low pass 
filter of the price.
 
So another alternative, which would eliminate an adjustment parameter (one 
of the periods) would be to say:
      value = (price - slow) * 2 / (slowPeriod +1)
 
It is also a correct calculation of velocity except witha  single low pass 
filter instead of two (less heavily filtered, less lag)
 
There may be some benefit to the above.. I just thought that the current 
implementation where the scalign of the velocity changes with the period 
selection would obscure other relationships.
 
I'll try coding them and trying them tomorrow to see if they make any 
difference (anmd to debug to see if I made a mistake).
 

-- 
You received this message because you are subscribed to the Google Groups 
"JBookTrader" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jbooktrader.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to