File Exchange

image thumbnail

Trading Algorithms Using Signal Processing in MATLAB

version 1.0.5 (1.29 MB) by Steve Rogers
This book was written to aid in research into signal processing algorithms with application to trading.


Updated 25 Dec 2020

View Version History

View License

The text is organized into 4 chapters. Chapter 1 Signal Processing presents filters that mitigate the effects of noise. Filters use fixed and adaptive methods. Chapter 2 Indicators has oscillators that utilize the various filter structures of Chapter 1. Most of the popular oscillators are represented. Chapter 3 Scalping Indicators show some of the approaches that may be applied to short time frames (1 to 30 minute sample rates). Chapter 4 Ehler’s Filters and Indicators is dedicated to the many contributions of John F. Ehlers. The author drew heavily from, which has thousands of scripts written in their proprietary Pine Script language. Also, there is a large listing of indicator ideas on the link, which is titled LazyBear Custom Indicators for TradingView.

Cite As

Steve Rogers (2021). Trading Algorithms Using Signal Processing in MATLAB (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Valeri Disko

Thank you, Steve

Steve Rogers

Hi all, The latest submission is to correct divide by zero errors that I have found. Please let me know if you have found other errors. Best regards.

Steve Rogers

Dear Sinan, I don't get that error. Sorry that you do.
bsm is a 1x4 vector. Therefore bsm' becomes a 4x1 vector which will multiply with XehlCyb.prwin which is a 4x150 matrix. Do you get different dimensions?
Best regards,

Sinan Islam

I get error: "Matrix dimensions must agree", When I run EhlerCyberCyc.
The error is generated at line: Smooth2 = sum(bsm'.*XehlCyb.prwin);

Valeri Disko

Thank you very much for the code!

Sinan Islam

Steve Rogers

Dear xiaokui, I appreciate your comment. There are nearly 130 algorithms presented in the text and there are likely to have some errors creep in. I tried to ensure accuracy, however, I would appreciate your informing me of any mistakes you find. I will correct them as soon as I can.

Steve Rogers

The following description of VWAP is from
There are five steps in calculating VWAP:

Calculate the Typical Price for the period.
[(High + Low + Close)/3)]
Multiply the Typical Price by the period Volume.
(Typical Price x Volume)
Create a Cumulative Total of Typical Price.
Cumulative(Typical Price x Volume)
Create a Cumulative Total of Volume.
Divide the Cumulative Totals.
VWAP = Cumulative(Typical Price x Volume) / Cumulative(Volume)

Hope this helps.

xiaokui wang

I ran through some of the code in the book. A little confused. VWAP calculations, for example, obviously don't get the right results。
function out = VWAP(H,L,C,V)
Price = (H+L+C)/3;
Len = 14;
persistent Xvwap
if isempty(Xvwap)
Xvwap.vwapwin = repmat(Price.*V,Len,1);
Xvwap.volwin = repmat(V,Len,1);
Xvwap.vwapwin = [Price.*V;Xvwap.vwapwin(1:end-1,:)];
Xvwap.volwin = [V;Xvwap.volwin(1:end-1,:)];
vwa = sum(Xvwap.vwapwin);
vol = sum(Xvwap.volwin);
vwap = vwa./vol;
out(1,:) = vwap;

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Chapter1 - signalProc



chapter2 Indicators