The Elite Circle - Lag Calculation for Octave (MatLab)
futures io

Categories Help    

The Elite Circle
File sharing for Elite Members only, includes any and all platforms and file types

Lag Calculation for Octave (MatLab) 1 *
This script is inspired by John Ehlers works on using DSP for trading. His books and articles contain formulas that estimate lag for some indicators. However, how to estimate lag in general case?

This script uses the DFT Phase Response (PhR) to make this estimation. The negative shift in the PhR pushes the values to the right, thus delaying the signal. The raw PhR returns the angle value. However, we want to estimate lag in terms of bars (time delay). To do it, we need to take an account the frequency (or period) of the phase:

Lag = | min(Phase * Period) | = | min(Phase / Frequency) |

Then we need to take the minimal value and take its absolute value. We skip all frequencies above 0.5 (the maximum possible without aliasing).

Version: 0.1.1



>> a = [1];
>> b = [1/3,1/3,1/3];
>> lag(b,a)
ans = 1.0000


>> a = [1,-0.9];
>> b = [0.1];
>> lag(b,a)
ans = 9.0000

Category The Elite Circle 
Suggest other entries I might like
Details: Lag Calculation for Octave (MatLab)
Category: The Elite Circle 

June 30th, 2014
Size: 2.17 KB
Downloaded: 1 times


Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada),
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.