Dear friends,
Now I explain the details of the study. I am giving a very detailed explanation. It may be boring for some of you who just want to see the results and the program codes. But you have to wait till the third part for that. These details help in two ways: firstly, for all those seniors with vast knowledge of trading and TA, it gives a chance to critically go through the results and the testing methodology. In turn they will be able to guide us more effectively by pointing out any flaws in the strategies and also suggest more effective steps to be incorporated. Secondly, for all those new entrants and those who want to take up similar studies, it gives them an opportunity to create their scenarios more effectively.
1. SELECTION OF DATABASE:
EOD data of NSE stocks is used. No BSE stocks.
2. SELECTION OF STOCKS:
I have selected 30 stocks. The selection was random. I listed all the NSE stocks alphabetically. Then I generated 30 random numbers. Random numbers can be generated easily by any programming language. Some calculators also generate random numbers. I selected those stocks whose serial number in my list matched with the random number generated. The list consists of:
ABB, ACC, ALEMBIC, AMARAJA, ASIANELEC, BAJAJAUTO, CADILLAHC, CENTBOP, COMSYS, CRANESSOFT, DABUR, DHAMPURSUG, EDUCOMP, EICHER, ESCORTS, GRASIM, HEROHONDA, HIMACHALFUT, INDSWFTLTD, INFOSYSTCH, LT, LUPIN, MASTEK, RELIANCE, SATYAMCOMP, SBIN, TAJGVK, TATASTEEL, VSNL, ZEETELE.
A couple of these stocks do not have sufficient historical data. But I have still included them because:
a) As random selection is adopted, I do not want to reject some of the selected stocks as it introduces bias in selection.
b) It also gives us a chance to see how the strategies work with a limited amount of data.
3. SELECTION OF TIME PERIODS FOR TESTING:
There are seven different conditions:
i) Long Term-I: This is from Jan 05 to Sep 06. The reason for selecting this period is my personal choice.
ii) Long Term-II: This is from Jan 02 to Jun 03. This was suggested by Sanjay. He has already explained why he suggested this period.
iii) Range bound: Every stock goes through a phase of no trend and trades in a narrow range. For each of the 30 selected stocks, I have manually scanned through the charts and selected the time period by visual inspection. No indicators like RAVI, MACD, TRENDCHK etc. were used. The only condition was that the range bound period should be at least two months.
iv) Down Trend: Again, every stock goes through a phase where its price goes on falling. For each stock this time period was also selected by visual inspection of the charts. Same condition as above, that the downtrend period should be at least two months and it should be outside the market crash period (explained below).
v) Three market crash time periods: When market crashes (the index falls rapidly) almost all stocks follow the same downtrend.
I have selected three such crashes. This selection was based on the fall in the SENSEX. The period starts with the day when the SENSEX reaches a peak value before the crash and ends with the day when it raches the lowest value and thereafter starts recovering without major falls. The following three periods were selected:
a) Feb 14, 2000 to May 23, 2000 (SENSEX fell from 6150.69 on 14-2-2000 to 3831.86 on 23-5-2000).
b) Apr 23, 04 to Jun 24, 04 (SENSEX fell from 5979.25 on 23-4-04 to 4613.94 on 24-6-04. On 15-5-04 it reached 4227.5 but the down trend continued till Jun 24).
c) The most recent fall from May 10, 2006 to Jun 14, 2006 (SENSEX fell from 12624.4 on 10-5-06 to 8799.01 on 14-6-06).
4. RULES TO BE ADHERED TO DURING TESTING:
I have imposed the following rules for the testing procedure.
a) As Karthik has already mentioned in the beginning of this thread, the strategy should be simple. I have also followed this principle. No complicated conditions or indicators for BUY or SELL.
b) All BUY and SELL signals will be strictly followed. However, the original MABIUTS of Karthik gives consecutives BUY or SELL signals without giving the opposite signal in between. In such multiple signals of same kind only the first signal will be taken, all subsequent signals ignored and wait for the opposite signal to generate. In the remaining three strategies alternate BUY and SELL signals are always generated.
c) NO STOP LOSS. As I have imposed the condition to trade all signals I have not put a stop loss condition. A stop loss can be incorporated later if it is beneficial.
d) All trades will be cash segment, delivery based trades.
e) For each time period we start with only cash. No stocks in our portfolio. Also, NO SHORT SELLING. So, our entry is always by buying the stock. At the end of the period, we come out with only cash. No open positions. So, our last trade will be a SELL. Even if a BUY condition comes at the end of the period, we ignore it as we cannot close it. If we get only BUY signals (or only SELL signals) in the testing time zone we discard them and note this as NVS (No Valid Signals) Similarly, if there is only one SELL and only one BUY in the entire period occuring in reverse order (SELL followed by BUY), this also is taken as NVS.
f) If there is no data for the testing period it is noted as NDA (No Data Available). This happens for the stocks listed recently.
g) No complete reinvesting of profits. After selling a stock with profit, we buy the same number of stocks back when a BUY condition comes. We take out the required money from the previous sale proceedings and keep the excess money. If we incur loss in previous selling then we provide additional funds for next BUY so that same number of shares can be purchased. This makes calculation of profits easy (By following this rule the percent profit/loss will be based on the first buying price only).
5. WHEN TO BUY AND SELL:
We are dealing with EOD data. All of the strategies use Close price for generating the signals. Therefore, a BUY/SELL signal is available only at the end of the trading day, when the market closes. So, we can only trade on the next trading day. Therefore, the prices on the next trading day are used.
6. WHAT IS THE BUY/SELL PRICE:
This is difficult to decide. Ideally, we want to SELL at the highest and BUY at the lowest price. But we cannot predict these prices. For back testing we can use these values, as the data is already available. But in real life it is not possible. I have seen people using the Closing price or average price or some such derived price. These are also difficult to get in real situation. Therefore, I use the Opening Price for all my calculations. I would also give a somewhat vague explanation for using Open price: A SELL signal means the prices are going to fall. Naturally we try to sell as early as possible before further fall in prices. A BUY signal means the prices are going to rise and we try to buy as early as possible before the prices go up further. In both cases the Open price would be more suitable. The choice of BUY or SELL price is open for discussion.
7. CALCULATION OF PROFIT/LOSS:
For comparing the results percent gain or loss is used. The percentage of profit/loss is based on the price at which the initial purchase was made (Explained above in Para 4 (g)). Although the percent profit/loss can be used for comparison, there is one more problem in real situations. This is brokerage and taxes. As we pay brokerage and taxes for both buying and selling, our real profits are reduced by the sum of these additional costs. It is not possible to fix a brokerage and tax component as different brokers charge different amounts. For my calculations I have taken a moderate rate of brokerage of 0.5% which is quite common. Add to this the STT and service charges etc. So, I take an overall figure of 0.65%. Using this I have calculated net profit/loss. I am giving both these figures, the total profit/loss excluding brokerage and taxes and the net profit/loss after accounting for the additional costs. This makes the comparison of the results more effective. From the results that I would be giving later, you can see that in some cases although there is substantial profit in gross terms, in real terms there is considerable loss due to the transaction charges.
This is all for the Details of my "Experiments in TA". This post has already become quite lengthy. So, I stop here and post the details of the strategies, the AFL codes and results in my next part of this series. The next parts will not be so lengthy.
I once again call for your comments, suggestions and evaluation.
Regards and Happy trading.
-Anant