<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: The MAD indicator	</title>
	<atom:link href="https://financial-hacker.com/the-mad-indicator/feed/" rel="self" type="application/rss+xml" />
	<link>https://financial-hacker.com/the-mad-indicator/</link>
	<description>A new view on algorithmic trading</description>
	<lastBuildDate>Thu, 11 Nov 2021 06:46:13 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Quantocracy&#039;s Daily Wrap for 10/13/2021 - Quantocracy		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-76704</link>

		<dc:creator><![CDATA[Quantocracy&#039;s Daily Wrap for 10/13/2021 - Quantocracy]]></dc:creator>
		<pubDate>Thu, 11 Nov 2021 06:46:13 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-76704</guid>

					<description><![CDATA[[&#8230;] The MAD indicator [Financial Hacker] [&#8230;]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] The MAD indicator [Financial Hacker] [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arnis Lapsa		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75896</link>

		<dc:creator><![CDATA[Arnis Lapsa]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 15:00:24 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75896</guid>

					<description><![CDATA[In other news:

	vars Signals = series(PPO(smoothed, period*.5, period, MAType_SMA));	
	vars Signals = series(MAD(smoothed,period*.5, period));

I guess MAD sounds catchier.]]></description>
			<content:encoded><![CDATA[<p>In other news:</p>
<p>	vars Signals = series(PPO(smoothed, period*.5, period, MAType_SMA));<br />
	vars Signals = series(MAD(smoothed,period*.5, period));</p>
<p>I guess MAD sounds catchier.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arnis Lapsa		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75866</link>

		<dc:creator><![CDATA[Arnis Lapsa]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 06:30:08 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75866</guid>

					<description><![CDATA[Tested. You are correct.

&#062; var* Out = series(0,Length);

Crashes fixed.
Tricky series - sometimes I forget that Lite C compiles.

&#062; I suppose that AutocorrelationPeriodogramCycle is similar to the Zorro DominantCycle function

Yes. But instead of Hilbert&#039;s Transform it uses autocorellation or something (my memory is starting to fade) to detect dominant cycle length. Ehler advocates against usage of HT.

Sadly my implementation is sluggish and perhaps even faulty. But I did observe some really promising numbers here and there. I would be happy to see a blog post with a robust implementation of it.  ;)]]></description>
			<content:encoded><![CDATA[<p>Tested. You are correct.</p>
<p>&gt; var* Out = series(0,Length);</p>
<p>Crashes fixed.<br />
Tricky series &#8211; sometimes I forget that Lite C compiles.</p>
<p>&gt; I suppose that AutocorrelationPeriodogramCycle is similar to the Zorro DominantCycle function</p>
<p>Yes. But instead of Hilbert&#8217;s Transform it uses autocorellation or something (my memory is starting to fade) to detect dominant cycle length. Ehler advocates against usage of HT.</p>
<p>Sadly my implementation is sluggish and perhaps even faulty. But I did observe some really promising numbers here and there. I would be happy to see a blog post with a robust implementation of it.  😉</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Petra Volkova		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75820</link>

		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Wed, 20 Oct 2021 11:29:16 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75820</guid>

					<description><![CDATA[I just noticed a potential crash by this line:

var period = AutocorrelationPeriodogramCycle(Price); // that one from `Cycles for whatnot` book
vars Signals = series(MADH(Price,period*.5, period));

I suppose that AutocorrelationPeriodogramCycle is similar to the Zorro DominantCycle function, but the returned cycle will then be different at each bar, while my hann() function allocated a fixed length series. Fix it by not using a fixed length:

vars hann(vars Data,int Length)
{
	vars Out = series();
	int i;
	for(i=0; i&#060;Length; i++)
		Out[i] = Data[i] * (1-cos(2*PI*(i+1)/(Length+1)));
	return Out;
}

So it&#039;s not a zero price after all... ]]></description>
			<content:encoded><![CDATA[<p>I just noticed a potential crash by this line:</p>
<p>var period = AutocorrelationPeriodogramCycle(Price); // that one from `Cycles for whatnot` book<br />
vars Signals = series(MADH(Price,period*.5, period));</p>
<p>I suppose that AutocorrelationPeriodogramCycle is similar to the Zorro DominantCycle function, but the returned cycle will then be different at each bar, while my hann() function allocated a fixed length series. Fix it by not using a fixed length:</p>
<p>vars hann(vars Data,int Length)<br />
{<br />
	vars Out = series();<br />
	int i;<br />
	for(i=0; i&lt;Length; i++)<br />
		Out[i] = Data[i] * (1-cos(2*PI*(i+1)/(Length+1)));<br />
	return Out;<br />
}</p>
<p>So it&#8217;s not a zero price after all&#8230; </p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Petra Volkova		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75752</link>

		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 10:36:01 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75752</guid>

					<description><![CDATA[When fed with a price series of zeros, MAD will indeed crash as you see in the code: division by zero. Many indicators crash on zeros, so rule #1 for a crash free system is don&#039;t use it with a price of 0. But merely missing prices should be no problem.]]></description>
			<content:encoded><![CDATA[<p>When fed with a price series of zeros, MAD will indeed crash as you see in the code: division by zero. Many indicators crash on zeros, so rule #1 for a crash free system is don&#8217;t use it with a price of 0. But merely missing prices should be no problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arnis Lapsa		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75716</link>

		<dc:creator><![CDATA[Arnis Lapsa]]></dc:creator>
		<pubDate>Mon, 18 Oct 2021 21:04:40 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75716</guid>

					<description><![CDATA[Tinkered bit more.

Somehow - hann window ain&#039;t playing along.
In fact - MADH function straight up crashes for me like 3 times out of 5.
(could couple missing ticks cause division by zero? I&#039;m too lazy to figure out)

Partly cause of crashes (not enough curve fitting) - pure MAD indeed looks more promising.

- 60 BarPeriod
- dominant cycle via Zorro&#039;s inbuilt Hilbert Transform&#039;s `DominantPeriod` w/ sensitivity on 27

&#062; Trades 549  Win 48.6%  Avg +51.9p  Bars 5
&#062; AR 221%  PF 1.37  SR 0.00  UI 0%  R2 1.00

But the actual reason why I&#039;m writing this reply, @Sam, is...

`vars Signals = series(MAD(series(Smooth(Price, 6)),period*.5, period));`

With some slight smoothing my ground breaking back test numbers turn into:

&#062; Trades 485  Win 48.2%  Avg +70.2p  Bars 5
&#062; AR 263%  PF 1.49  SR 0.00  UI 0%  R2 1.00

P.s. My Sharpe Ratio is still bOrked.]]></description>
			<content:encoded><![CDATA[<p>Tinkered bit more.</p>
<p>Somehow &#8211; hann window ain&#8217;t playing along.<br />
In fact &#8211; MADH function straight up crashes for me like 3 times out of 5.<br />
(could couple missing ticks cause division by zero? I&#8217;m too lazy to figure out)</p>
<p>Partly cause of crashes (not enough curve fitting) &#8211; pure MAD indeed looks more promising.</p>
<p>&#8211; 60 BarPeriod<br />
&#8211; dominant cycle via Zorro&#8217;s inbuilt Hilbert Transform&#8217;s `DominantPeriod` w/ sensitivity on 27</p>
<p>&gt; Trades 549  Win 48.6%  Avg +51.9p  Bars 5<br />
&gt; AR 221%  PF 1.37  SR 0.00  UI 0%  R2 1.00</p>
<p>But the actual reason why I&#8217;m writing this reply, @Sam, is&#8230;</p>
<p>`vars Signals = series(MAD(series(Smooth(Price, 6)),period*.5, period));`</p>
<p>With some slight smoothing my ground breaking back test numbers turn into:</p>
<p>&gt; Trades 485  Win 48.2%  Avg +70.2p  Bars 5<br />
&gt; AR 263%  PF 1.49  SR 0.00  UI 0%  R2 1.00</p>
<p>P.s. My Sharpe Ratio is still bOrked.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Arnis Lapsa		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75657</link>

		<dc:creator><![CDATA[Arnis Lapsa]]></dc:creator>
		<pubDate>Sun, 17 Oct 2021 21:23:15 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75657</guid>

					<description><![CDATA[Well...

&#062; According to Ehlers, the two periods should differ by half the period of the dominant cycle in the data.

I don&#039;t think static 8-23 are a good representation of that.

After like 10 minutes of fiddling around - got some sort of success.

```
function run() 
{
	set(NFA&#124;PLOTNOW&#124;PRELOAD&#124;PARAMETERS);
	BarPeriod = 30;
	Outlier = 0;
	LookBack = 320;
	StartDate = 20210501;
	EndDate = 20211231;
	Lots = 10;
	Verbose = 2;
	MaxLong = MaxShort = 1;
	var* Price = series(price());
	var period = AutocorrelationPeriodogramCycle(Price); // that one from `Cycles for whatnot` book
	
	vars Signals = series(MADH(Price,period*.5, period));

	if(peak(Signals))
		enterShort();
	else if(valley(Signals))
		enterLong();
}
```

```
madh compiling...........
Test: madh MATICUSDT 2021
Monte Carlo Analysis... Median AR 66%
Win 16.91$  MI 3.09$  DD 8.86$  Capital 34.40$
Trades 400  Win 47.5%  Avg +42.3p  Bars 14
AR 108%  PF 1.22  SR 0.00  UI 0%  R2 1.00
```

PF 1.22 ain&#039;t that bad for such a system.

@Sam

&#062; Have you found any of his DSP work / indicators that are useful in an algo trading system?

yes]]></description>
			<content:encoded><![CDATA[<p>Well&#8230;</p>
<p>&gt; According to Ehlers, the two periods should differ by half the period of the dominant cycle in the data.</p>
<p>I don&#8217;t think static 8-23 are a good representation of that.</p>
<p>After like 10 minutes of fiddling around &#8211; got some sort of success.</p>
<p>&#8220;`<br />
function run()<br />
{<br />
	set(NFA|PLOTNOW|PRELOAD|PARAMETERS);<br />
	BarPeriod = 30;<br />
	Outlier = 0;<br />
	LookBack = 320;<br />
	StartDate = 20210501;<br />
	EndDate = 20211231;<br />
	Lots = 10;<br />
	Verbose = 2;<br />
	MaxLong = MaxShort = 1;<br />
	var* Price = series(price());<br />
	var period = AutocorrelationPeriodogramCycle(Price); // that one from `Cycles for whatnot` book</p>
<p>	vars Signals = series(MADH(Price,period*.5, period));</p>
<p>	if(peak(Signals))<br />
		enterShort();<br />
	else if(valley(Signals))<br />
		enterLong();<br />
}<br />
&#8220;`</p>
<p>&#8220;`<br />
madh compiling&#8230;&#8230;&#8230;..<br />
Test: madh MATICUSDT 2021<br />
Monte Carlo Analysis&#8230; Median AR 66%<br />
Win 16.91$  MI 3.09$  DD 8.86$  Capital 34.40$<br />
Trades 400  Win 47.5%  Avg +42.3p  Bars 14<br />
AR 108%  PF 1.22  SR 0.00  UI 0%  R2 1.00<br />
&#8220;`</p>
<p>PF 1.22 ain&#8217;t that bad for such a system.</p>
<p>@Sam</p>
<p>&gt; Have you found any of his DSP work / indicators that are useful in an algo trading system?</p>
<p>yes</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Petra Volkova		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75590</link>

		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Sat, 16 Oct 2021 11:37:38 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75590</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://financial-hacker.com/the-mad-indicator/#comment-75568&quot;&gt;Sam&lt;/a&gt;.

Ehlers old indicators are absolutely useful, especially his frequency filters. We are using them all the time.

But it is indeed not so with his recently invented indicators. I have yet to see a useful application for them.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://financial-hacker.com/the-mad-indicator/#comment-75568">Sam</a>.</p>
<p>Ehlers old indicators are absolutely useful, especially his frequency filters. We are using them all the time.</p>
<p>But it is indeed not so with his recently invented indicators. I have yet to see a useful application for them.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sam		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75568</link>

		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Fri, 15 Oct 2021 17:12:07 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75568</guid>

					<description><![CDATA[It seems like all of Ehlers ideas falls apart when tested objectively.
Have you found any of his DSP work / indicators that are useful in an algo trading system? I have been banging my
Head against the wall and have tried various smoothers and filters.]]></description>
			<content:encoded><![CDATA[<p>It seems like all of Ehlers ideas falls apart when tested objectively.<br />
Have you found any of his DSP work / indicators that are useful in an algo trading system? I have been banging my<br />
Head against the wall and have tried various smoothers and filters.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Henry Stern		</title>
		<link>https://financial-hacker.com/the-mad-indicator/#comment-75448</link>

		<dc:creator><![CDATA[Henry Stern]]></dc:creator>
		<pubDate>Tue, 12 Oct 2021 23:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4208#comment-75448</guid>

					<description><![CDATA[As is explained in “An Introduction to Digital Signal Processing for Trend Following” (https://alphaarchitect.com/2020/08/13/an-introduction-to-digital-signal-processing-for-trend-following/), taking the difference between two moving averages with different lengths, as with the Moving Average Difference (MAD) indicator, results in a bandpass filter. A bandpass filter passes frequencies within a low and high cutoff frequency band (the bandwidth) and attenuates the others. The filter has a center (also called “resonant”) frequency between the two cutoff frequencies which it passes at maximum power. The filter bandwidth and center frequency are determined by the two moving average lengths. That is, the two moving average lengths &quot;tune&quot; the filter to a specific bandwidth and center frequency.

If you are able to identify the &quot;dominant frequency&quot; of an input signal, you can determine the two moving average lengths that will produce the desired bandwidth and center frequency, as illustrated in the 30 period sine wave example. However, financial time series are generally non-stationary, meaning that the dominant frequency changes over time. As a result, a bandpass filter with fixed coefficients will generally work better in certain time periods than others when used with a particular financial time series, but it will not perform well at all times with all time series for trading purposes. The dominant frequency of the input needs to be somewhat close to the bandpass filter center frequency, otherwise the filter output will lead or lag the input (often referred to as &quot;divergence&quot;), as is explained in the introduction to DSP article. Adding a window function, such as the Hann window, smooths the MAD indicator output but at the cost of some additional phase delay (lag), as will any window function (some more than others). There is an unavoidable tradeoff between smoothing and phase delay with any type of filter.

Note that the Moving Average Difference (MAD) indicator is basically the same as the Moving Average Crossover (MAC) indicator, just interpreted differently. It is also similar to the Moving Average Convergence-Divergence (MACD) indicator, which uses the difference between two exponential smoothing filters with different smoothing constants instead of two moving averages. The introduction to DSP article examines these and other popular technical indicators in detail.]]></description>
			<content:encoded><![CDATA[<p>As is explained in “An Introduction to Digital Signal Processing for Trend Following” (<a href="https://alphaarchitect.com/2020/08/13/an-introduction-to-digital-signal-processing-for-trend-following/" rel="nofollow ugc">https://alphaarchitect.com/2020/08/13/an-introduction-to-digital-signal-processing-for-trend-following/</a>), taking the difference between two moving averages with different lengths, as with the Moving Average Difference (MAD) indicator, results in a bandpass filter. A bandpass filter passes frequencies within a low and high cutoff frequency band (the bandwidth) and attenuates the others. The filter has a center (also called “resonant”) frequency between the two cutoff frequencies which it passes at maximum power. The filter bandwidth and center frequency are determined by the two moving average lengths. That is, the two moving average lengths &#8220;tune&#8221; the filter to a specific bandwidth and center frequency.</p>
<p>If you are able to identify the &#8220;dominant frequency&#8221; of an input signal, you can determine the two moving average lengths that will produce the desired bandwidth and center frequency, as illustrated in the 30 period sine wave example. However, financial time series are generally non-stationary, meaning that the dominant frequency changes over time. As a result, a bandpass filter with fixed coefficients will generally work better in certain time periods than others when used with a particular financial time series, but it will not perform well at all times with all time series for trading purposes. The dominant frequency of the input needs to be somewhat close to the bandpass filter center frequency, otherwise the filter output will lead or lag the input (often referred to as &#8220;divergence&#8221;), as is explained in the introduction to DSP article. Adding a window function, such as the Hann window, smooths the MAD indicator output but at the cost of some additional phase delay (lag), as will any window function (some more than others). There is an unavoidable tradeoff between smoothing and phase delay with any type of filter.</p>
<p>Note that the Moving Average Difference (MAD) indicator is basically the same as the Moving Average Crossover (MAC) indicator, just interpreted differently. It is also similar to the Moving Average Convergence-Divergence (MACD) indicator, which uses the difference between two exponential smoothing filters with different smoothing constants instead of two moving averages. The introduction to DSP article examines these and other popular technical indicators in detail.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
