Experiments in Technical Analysis

kkseal

Well-Known Member
I think a shorter period MACD for the weekly would work better. Since we're using a 14d (26-12) MACD for the daily i think the period for the weekly should be something like (5, 10, 9) or (6, 12, 9)* - i.e. a 5/6 Wk MACD (approx twice the daily period).

Regards,
Kalyan.

* I am partial to this as there's an in-built symmetry in the nos. :)
 

asnavale

Well-Known Member
THE MABIUTS-HB SYSTEM : SOME IMPROVEMENTS​

Dear friends,

This thread was started by Karthik with the introduction of Moving Average based Trading system which he had named MABIUTS. Later I developed the MABIUTS-H system which is based on the histogram of difference between 15-day EMA and 15-day EMA of this EMA. The system gives the signals earlier than the Moving Average Cross-Over based systems. But it has a major drawback - it gives too many signals even in trending market conditions. This was improved by adding Bollinger bands of 5-days with 1 sigma width. This system was named MABIUTS-HB. The histogram crossing the bands were used as BUY/SELL signals. This reduced the number of signals and whipsaws considerably. The details can be read in my earlier posts in this thread. Even this system is sensitive to small changes in price and gives many whipsaws especially in sideway movement of the stock prices. I have been trying to reduce these whipsaws.

In order to reduce the sensitivity of the system to small changes in price I have introduced a threshold level beyond which the price should change in order to generate the BUY/SELL signals. This is similar to what Karthik had done using PEAK function. However the PEAK function was not satisfactory in case of MABIUTS-HB system. Therefore, I have looked for some other threshold conditions. Among different options tried out I found two of them promising. One method is based on short term simple moving average and other based on previous Highest/Lowest Close prices.

In the moving average based system the BUY signal is generated when the Histogram crosses above the upper Band AND the Closing price is equal to or above m-days moving average of the Closing price. Similarly SELL signal is generated when the Histogram crosses below the lower Band AND the closing price is equal to or lower than n-days moving average of the Closing price.

Similar strategy is used in the Highest/Lowest price based system. In this system the BUY signal is generated when the Histogram crosses above the Upper Band AND the Closing Price is equal to or above Highest Close price in the last m-days. Similarly, a SELL signal is generated when the Histogram crosses below the Lower Band AND the closing price is equal to or lower than the lowest Close price in the last n-days.

It is necessary to determine the values of m and n to get best possible signals. After experimenting with different values of m and n I found that for Buy condition the 9-day moving average was best while for SELL condition 3-day moving average was ideal. In case of the second strategy also I found that for BUY signal the threshold was Highest Close price in last 9-days and for SELL signal the Lowest price in last 3 days.

I have enclosed a figure (Fig_1.png) which shows the effect of introducing threshold condition. The figure has three charts one below the other. The topmost chart is based on original MABIUTS-HB system without any threshold condition. The middle chart is based on Hi/Lo price threshold. The bottom chart is based on Moving Average threshold. In the figure we can see a large number of signals in the top chart (without threshold condition) while the lower two charts have much fewer signals as a result of threshold condition. In the lower two charts the signals appear almost in same place.

I have enclosed the AmiBroker AFLs for both these variants of MABIUTS-HB system. Change the .TXT extension to .AFL to use them in AmiBroker. Just drag and drop the indicator on any price chart.

In most cases both the variants work equally well but there are some cases where one system is better than the other. I am enclosing two more figures to illustate the differences.

Fig_2 illustrates the difference between the MA based threshold and HI-Lo based threshold. The MA based system (bottom chart) has given BUY signal in December while the Hi/Lo based system (middle chart) has not given any Buy signal after November even though the price has almost doubled. Interestingly the original system without threshold (top chart) has given Buy signal in December and SELL signal in January. All these important points are shown by circles in the charts.

This may tempt us to adopt the MA based threshold. But wait. See Fig_3 for an interesting fact. The top chart is based on Hi-Lo threshold and it has given SELL signal in early May (Circled in the chart) and no signals thereafter till today. The lower chart shows SELL signal in end April (Circled in chart) and thereafter six pairs of BUY/SELL signals. A closer look at these later signals shows that these are worthless. Only the first pair between June-July gives some profit. Also, if we observe the trend the prices have continuously fallen since May except for a short duration in mid June to Mid July. The prices have fallen to nearly 30% of the prices prevailing in end of April. Therefore, the Hi-Lo based system has kept us out of trading during this fall. Does it mean the Hi-Lo based system is better?

So, now we have to decide which system to follow. The Hi-Lo based threshold or the MA based threshold? I am not able to answer this qusetion. I request you knowledgeable members, especially Karthik, Kalyan, Saaji and other seniors, to give your valuable comments and guidance.

Hi Karthik, I am following the developments in this thread. I would try the ASI and see the effect. Thanks for the suggestion.

Regards

-Anant
 
Last edited:
Hi Asnavale,

The above mentioned 2 AFL formula's are not giving me any charts in Amibroker. Am I missing something?
 

asnavale

Well-Known Member
Hi abhinkoi,

You should have a price chart already and then add the indicator by dragging on to the price chart.

Regards

-Anant
 

karthikmarar

Well-Known Member
I think a shorter period MACD for the weekly would work better. Since we're using a 14d (26-12) MACD for the daily i think the period for the weekly should be something like (5, 10, 9) or (6, 12, 9)* - i.e. a 5/6 Wk MACD (approx twice the daily period).

Regards,
Kalyan.

* I am partial to this as there's an in-built symmetry in the nos. :)
Thanks kalyan,

I forgot to mention that I use a MACD (8,17,9) for the weekly. As I understand Originally Gerald Appel used (8,17,9) for Buys and (12,26,9) for Sells. Ofcourse my afl which will be posted soon has the feature to select the period for both daily and weekly MACD.

regards

Karthik
 

oxusmorouz

Well-Known Member
Sorry for deviating from the topic....thought this was a useful tool
Here's an indicator which can calculate the number of bars from a specific date in metastock:
Put this in indicator builder:

a:= Input("day",1,31,5);
b:= Input("month",1,12,5);
d:= Input("year",0000,9999,2005);
{Plot in own window}
BarsSince(DayOfMonth() = a AND Month() = b AND Year() = d)

Enter the day,month and year number (for say, 10th june 2006, enter 10 for day, 6 for month and 2006 for year)
 

kkseal

Well-Known Member
Thanks kalyan,

I forgot to mention that I use a MACD (8,17,9) for the weekly. As I understand Originally Gerald Appel used (8,17,9) for Buys and (12,26,9) for Sells. Ofcourse my afl which will be posted soon has the feature to select the period for both daily and weekly MACD.

regards

Karthik
Hi Karthik,

Mistakenly thought you were using the same periods for daily & weekly MACD. Actually, couldn't make out from the chart you posted. This clarifies things.

I have used a (8,18,9) MACD on the Weekly to fairly good effect. Sell when i see a distinct dip &/or biggish -ve divergence viz a viz prce. (Usually the RSI on the daily warns me beforehand & the MACD dip/divergence acts as the confirmation).

Regards,
Kalyan.
 

kkseal

Well-Known Member
The Accumulation/Distribution Line is a fairly good means to measure the force behind a move.
Out of all the 'avatars' of A/D the Williams' A/D seems to be the most scientific.

The Chaikin Oscillator is an indicator to predict changes in the Accumulation/Distribution Line. It is simply the Moving Average Convergence Divergence indicator (MACD) applied to the Accumulation/Distribution Line. (Usually the difference between the 3-day exponential moving average and the 10-day exponential moving average of the Accumulation/Distribution Line is used)

Just as MACD injects momentum characteristics into moving averages (it's actually nothing but the ROC of convg/divg of the 2 MAs), the Chaikin Oscillator gives momentum characteristics to the Accumulation/Distribution Line, which can be a bit of a laggard sometimes. By adding momentum features, the Chaikin Oscillator will lead the Accumulation/Distribution Line.

So what if we plot the Chaikin Oscillator based on Williams A/D (rather than the vintage A/D) and use it as a filter for our entries?

This can be tried in 2 ways :-

1) By introducing a Signal line for the CO and using cross-overs (as in MACD)
or
2) By using the PEAK function, with the CO values as the input array.

We can also mull using LRS & R2 on the CO with appropriate threshold lvls (as is already being used in one of the systems) or even an FT of CO (or the 'parent' A/D) ;)

A (3,13,9) or a (5,15,9) CO can be tried (to be more in sync with the trigger line EMA periods being used in the systems under test).

This will introduce an indicator into the systems, but they will still very much remain MA based systems as the CO too is nothing but a couple of EMAs & their MACD. The use of separate volume filter will also become redundant as the volume strength will be incorporated in the Williams' A/D.

The ideal use of CO is trading the divergences between it & the A/D line on which it is based; but this i guess would be difficult to implement in a mechanical trading system.

Regards,
Kalyan.
 
Last edited:
hI,
Good knowledge sharing for the learners like me. Thanks for that. Actually I was trying to make A/D (Larry williams) line in metastock but it is giving error of division by zero error. Please help in removing this error.

I am writing metastock coding here.
If(H-L<>0 AND C-O<>0,
If(C-O>0,PREV + PREC(((CLOSE-OPEN)/(HIGH-LOW)),2 ) * (VOLUME/10),
PREV - PREC(((CLOSE-OPEN)/(HIGH-LOW)),2 ) * (VOLUME/10)),
0)

But As I said I am getting division by zero error.

Please help me in clearing this error.

If any body has used A/D flow line of Larry williams then please tell me about the result as I am planning to use this in my trading.

Ashvin


The Accumulation/Distribution Line is a fairly good means to measure the force behind a move.
Out of all the 'avatars' of A/D the Williams' A/D seems to be the most scientific.

The Chaikin Oscillator is an indicator to predict changes in the Accumulation/Distribution Line. It is simply the Moving Average Convergence Divergence indicator (MACD) applied to the Accumulation/Distribution Line. (Usually the difference between the 3-day exponential moving average and the 10-day exponential moving average of the Accumulation/Distribution Line is used)

Just as MACD injects momentum characteristics into moving averages (it's actually nothing but the ROC of convg/divg of the 2 MAs), the Chaikin Oscillator gives momentum characteristics to the Accumulation/Distribution Line, which can be a bit of a laggard sometimes. By adding momentum features, the Chaikin Oscillator will lead the Accumulation/Distribution Line.

So what if we plot the Chaikin Oscillator based on Williams A/D (rather than the vintage A/D) and use it as a filter for our entries?

This can be tried in 2 ways :-

1) By introducing a Signal line for the CO and using cross-overs (as in MACD)
or
2) By using the PEAK function, with the CO values as the input array.

We can also mull using LRS & R2 on the CO with appropriate threshold lvls (as is already being used in one of the systems) or even an FT of CO (or the 'parent' A/D) ;)

A (3,13,9) or a (5,15,9) CO can be tried (to be more in sync with the trigger line EMA periods being used in the systems under test).

This will introduce an indicator into the systems, but they will still very much remain MA based systems as the CO too is nothing but a couple of EMAs & their MACD. The use of separate volume filter will also become redundant as the volume strength will be incorporated in the Williams' A/D.

The ideal use of CO is trading the divergences between it & the A/D line on which it is based; but this i guess would be difficult to implement in a mechanical trading system.

Regards,
Kalyan.
 

Similar threads