Experiments in Technical Analysis

asnavale

Well-Known Member
Re: Experiments in Technical Analysis - Trading the MACD

Hi Anant,

No new post from you for long time. Are you working on any new twist to Experiments in Technical Analysis.

Regards

*** Uma ***
Hello Uma,

I am Working ... Working ... Working ... Working ... Working ...

When I get something worth posting I will surely do. Thanks for your interest.

Regards

-Anant
 

kkseal

Well-Known Member
Hi Anant,

Just adding to my last post.

I use a shorter-term MA crossover filter in my own humble system. Works better than without one but i can tell you it's not perfect.

Regards,
Kalyan.
 

asnavale

Well-Known Member
Hi Kalyan,

I have already used this filter in the threshold based strategy. I have introduced 9-day MA for BUY and 3-day MA for SELL. Works well but not completely satisfactory. Similarly, in another option I have used last 9-day's highest Close as threshold for BUY and last 3-day's Lowest Close for SELL. This almost is same as the MA-based system. But has its own drawbacks. So, trying to find out some other alternative to filter whipsaws as much as possible.

Thanks for your interest and suggestions. Keep it up so that you may give me some idea to try out.

Regards

-Anant
 

asnavale

Well-Known Member
Re: Experiments in Technical Analysis - Trading the MACD

Hi Anant,

I have one request. In your modification to MABIUTS-HB system using Hi-Lo and MA thresholds you have given AFLs for each of them. Can you combine both and make a single AFL with provision for selecting either MA or HI-LO threshold? This will help in running a single AFL instead of two and visualising the differences better.

Regards

*** Uma ***
Hello Uma,

Here is the AmiBroker AFL code you wanted. You can select the MA-threshold or Hi-Lo threshold in Parameters Window whien you right-Click in the chart.

Code:
("MABIUTS-HB : Threshold Based");
 p1  = Param("EMA Period", 15, 1, 200, 1);
 p2  = Param("Smoothening Period", 15, 1, 200, 1);
 p3  = Param("Bollinger Period", 5, 3, 25, 1);
 p4  = Param("Bollinger Band Width", 1, 0.5, 3, 0.1);
 p5  = Param("Period for Buy", 9, 3, 50, 1);
 p6  = Param("Period for Sell", 3, 3, 50, 1);
 p7  = Paramtoggle("Threshold Based On", "MA | Hi-Lo", 1);

  X  = EMA(C, p1);
  Y  = EMA(X, p2);
  D  = X - Y;
BBB  = BBandBot(D, p3, p4);
BBT  = BBandTop(D, p3, p4);

 Buy  = Cross(D, BBT) AND (C >= MA(C, p5));
 Sell = Cross(BBB, D) AND (C <= MA(C, p6));

If (p7)
          {  Buy  = Cross(D, BBT) AND (C >= HHV(C, p5));
             Sell = Cross(BBB, D) AND (C <= LLV(C, p6));
          }

Buy  = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(shape, IIf(Buy, colorBrightGreen, colorRed), 0, IIf(Buy, L, H));
The same code is attached herewith as a text file. You can download the file, change the extension to .AFL and directly use in AmiBroker charts.

Regards

-Anant
 
Last edited:

asnavale

Well-Known Member
Thank you Uma

-Anant
 

asnavale

Well-Known Member
THE MABIUTS-HB WITH RSI

The Story so far:

The MABIUTS-HB system is based on difference between two Moving Averages. Any Moving Average based system is prone to whipsaws and MABIUTS-HB is no exception. I have tried to reduce the whipsaws in following ways:

  1. By introducing Bollinger Bands of the Histogram and BUY and SELL are based on the cross-over of the Histogram and the Bollinger Bands. This has resulted in some reduction in whipsaws.
  2. I further refined the system by introducing a filter. There are two alternatives for the Filter: one based on short term MA and another based on previous High or Low over a short period. Both of these are almost identical except in few specific cases. Both of these did reduce the whipsaws to a considerable level. But the occurrence of whipsaws is still a problem to be solved.
What is New now:

Karthik has recently suggested some kind of indicator based Filter though he did not specify which. I have tried a few different indicators and found that RSI can be used as a Filter to reduce whipsaws to a much more acceptable level, though not completely eliminating them.

I am describing now the RSI based Filter applied to MABIUTS-HB system.

The basic signal generation is the same as earlier which is based on Histogram crossing over the Bollinger Bands. But the signal is valid only when the RSI is also favourable. With few trials with different values of RSI, I found that BUY condition when RSI is above 50 and SELL condition when RSI goes below 50 are satsfactory.

The commonly used default period of 14 for RSI was found to be inadequate for this MABIUTS-HB system. After testing with different values I have chosen the RSI period of 21 which appears well suited to filter the whipsaws. Therefore, I have taken RSI(21) as the Filter.

The BUY and SELL conditions are therefore generated as follows:

BUY: Histogram crosses and goes above upper Bollinger Band AND RSI(21) is 50 or more.

SELL: Histogram crosses and goes below lower Bollinger Band AND RSI(21) is below 50.

Here the Bollinger Bands are those of the Histogram itself, with a period of 5 and width 1.

The AmiBroker AFL using this method to plot the BUY and SELL arrows on the price chart is given below. I have also attached the AFL file with this post to so that you need not type it. Just download it and directly use by changing the extension from 'txt' to 'AFL'.

Code:
("MABIUTS Histogram With RSI(21) Filter");
p1 = Param("EMA Period", 15, 1, 200, 1, 1);
p2 = Param("Smoothening Period", 15, 1, 200, 1, 1);
p3 = Param("Bollinger Band Period", 5, 3, 50, 1);
p4 = Param("Bollinger Band Width", 1, 1, 3, 1, 1);

 X = EMA(C, p1);
 Y = EMA(X, p2);
 D = X-Y;
 
BBB = BBandBot(D, p3, p4);
BBT = BBandTop(D, p3, p4);

Buy  = Cross(D, BBT) AND (RSI(21) > 49.99);
Sell = Cross(BBB, D) AND (RSI(21) < 50.00);

Buy  = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Marker = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(Marker, IIf(Buy, colorGreen, colorRed), 0, IIf(Buy, L, H));
I have enclosed three figures to show the effect of the Filters. each figure has three charts of the same stock. The bottom chart is without any Filter. The middle chart is with Hi-Lo Filter. The top chart is with RSI filter. In each figure you can see that the lower chart has too many signals. the middle chart has much reduced number of signals. The top chart has very few signals. These charts clearly show the pronounced effect of RSI based filter.

However, be aware that this is not the best solution. In several cases you can still see some whipswas, but less than the other options. On a casual observation I have seen in most cases when RSI oscillates between 45 and 55 the whipsaws are more. But if we use 45 and 55 as filter values the system performs poorly. Therfore, I have retained the RSI(21) Filter value of 50.

There is a need to address this problem. Your critical evaluation, comments and suggestions are needed. Please feel free to post your opinion.

Thanks

-Anant
 
Last edited:

kkseal

Well-Known Member
Hi Anant,

Excellent charts - brought out the differences clearly. Only in the case of Wipro there was a false sell signal during a consolidation phase.

Simce your system uses a 15d EMA and a smoothened version of it as the trigger line, i am not surprised that the conventional 14d RSI didn't work for you.

This seems better than all the filters that have been tried so far.

Regards,
Kalyan.
 

asnavale

Well-Known Member
Hi Kalyan,

In the case of WIPRO, the region of consolidation where false BUY/SELL signals were generated, was in mid July 2006. During this period the RSI(21) was between 45 and 55. This observation I have mentioned in the post. It appears that in general, when RSI(21) is oscillating between 45 and 55, the signals generated are likely to be false. Need more observations to confirm it.

Regards

-Anant
 
Bollinger Band Gap

Hi All,

I am trying to use this formula but its giving me error in Amibroker. Can someone help me out in rectifying the error -

I am getting this error -
Error 29,
Variable "bbtopsell" used without having been initialized

Please help.
Thanks in advance.

Cheers
Abhi
 
Last edited:

Similar threads