Traderji.com - Discussion forum for Stocks Commodities & Forex

Experiments in Technical Analysis

Discuss Experiments in Technical Analysis at the Technical Analysis within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Jorgen T, Exact replica of Peak function is not available in public domain,however many use ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > METHODS & STRATEGIES > Technical Analysis

Notices

Technical Analysis Discussion of all the principles involved in technical analysis.


Advertise Here

Reply
 
Thread Tools
Sponsored Links
  #841  
Old 28th March 2007, 06:55 AM
Moderator
 
Join Date: Nov 2005
Posts: 10,249
Thanks: 1,028
Thanked 1,957 Times in 779 Posts
uasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond repute
Reputation: 2033
Default Re: Experiments in Technical Analysis

Jorgen T,
Exact replica of Peak function is not available in public domain,however many use HHV function instead.

Asish
Reply With Quote
Sponsored Links
  #842  
Old 29th March 2007, 04:01 PM
Member
 
Join Date: Sep 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
indrag91 is on a distinguished road
Reputation: 20
Default Re: Experiments in Technical Analysis

Quote:
Originally Posted by asnavale View Post
CONTINUING WITH MACD



Code:
("Moving Average Cross-over Trading System");

MACDswitch = ParamToggle("Use MACD?", "No | Yes", 0); 
ShortEMA   = EMA(C, 5);
LongEMA    = EMA(O, 6);

 M = MACD();
 S = Signal();

 Buy  = Cross(ShortEMA, LongEMA);
 Sell = Cross(LongEMA, ShortEMA);

if (MACDswitch)
	{
		Buy  = Cross(ShortEMA, LongEMA) AND M > S;
		Sell = Cross(LongEMA, ShortEMA) AND M < S;
	}

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

Marker = Buy * shapeUpArrow + Sell * shapeDownArrow;
MarkerColor = IIf(Buy, colorBrightGreen, colorRed);
MarkerDist = IIf(Buy, L, H);
//You can uncomment next two lines if you want to plot the EMAs also

//Plot(ShortEMA, "EMA5 Close", colorGreen);
//Plot(LongEMA, "EMA6 Open", colorRed);

PlotShapes(Marker, MarkerColor, 0, MarkerDist);
Dear Mr.Anant
It seems working nice. I would like to back test it using amibroker but when i scanned, it shows all trades of EMA cross. If i try for back test with shorts and longs it gives error message "Missing short/cover variable assingnment".

I would like to test only for the trades of EMA cross overs, with MACD as u have given in AFL.

I am new to backtesting can u guide me with settings to be made in backtester. I am testing with Nifty charts.

Can u add the display of rates in the chart whenever buy / sell arrow is triggered.

Raj
Reply With Quote
  #843  
Old 29th March 2007, 09:19 PM
Member
 
Join Date: Dec 2005
Location: Hyderabad
Posts: 326
Thanks: 0
Thanked 1 Time in 1 Post
asnavale is on a distinguished road
Reputation: 30
Default Re: Experiments in Technical Analysis

Quote:
Originally Posted by indrag91 View Post
Dear Mr.Anant
It seems working nice. I would like to back test it using amibroker but when i scanned, it shows all trades of EMA cross. If i try for back test with shorts and longs it gives error message "Missing short/cover variable assingnment".

I would like to test only for the trades of EMA cross overs, with MACD as u have given in AFL.

I am new to backtesting can u guide me with settings to be made in backtester. I am testing with Nifty charts.

Can u add the display of rates in the chart whenever buy / sell arrow is triggered.

Raj
Hi Raj,

The AFL I had attached was for using as an indicator. For Exploring and backtesting you have to change it slightly. I don't know whether you have made the necessary changes. I am attaching the AFL required for Exploring/backtesting with this message. Try this AFL and give your feedback. This AFL has only Buy and Sell codes. There are no separate Short/Cover codes. Short is same as Sell and Cover is same as Buy.

Note that the attached file has .txt extension which should be changed to .afl before using in AmiBroker.

To use the AFL to include MACD also, set the MACD selection switch appropriately in Exploration window parameters before running Exploration/Back testing.

It is possible to add The price to the charts but it works only in AmiBroker version 4.8 and higher. Therefore I did not add the code so that users with lower versions can also use it. I can give you the additional code also but please let me know which price you want to display? Is it Open or Close or any other?
Regards

-Anant
Attached Files
File Type: txt EMAC5O6Expl.txt (723 Bytes, 56 views)

Last edited by asnavale; 29th March 2007 at 09:27 PM.
Reply With Quote
  #844  
Old 29th March 2007, 09:30 PM
Member
 
Join Date: Mar 2007
Location: GUJARAT
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
VISHAL JAIN is on a distinguished road
Reputation: 20
Default Re: Experiments in Technical Analysis

It is great idea specially for we jun'r members

i will b g8ful.
Reply With Quote
  #845  
Old 29th March 2007, 11:22 PM
Moderator
 
Join Date: Jul 2005
Location: kuwait
Posts: 1,456
Blog Entries: 5
Thanks: 45
Thanked 549 Times in 102 Posts
karthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to all
Reputation: 629
Default Re: Experiments in Technical Analysis

Quote:
Originally Posted by pdx05 View Post
Thank you Asish for your information on hindsight indicators. Do you have any clue as to what indicator could be used instead of hindsight indicators such as Zig Zag/Peak in order to establish the trend? I've found that the system (K1) will work well in trending periods, but not in ranging periods.

Karthik, I'd love to hear your thoughts on this.

Regards,
Jørgen T.
Hi Jorgen

Yes it is true that Mabiuts K1 works well in a trending market . The idea behind this system was keep one away in a ranging market. I will explain a bit. The value “y” in the afl is a adaptive EMA. Based on the ADX or RAVI value the EMA factor is adjusted. Below a certain value of the ADX (which indicates a non trending market) the factor is pegged to a constant so that the EMA becomes a straight line. The BUY condition is when the “y” is greater that a signal line which is an EMA (6) of the “y” itself. In a ranging market “y” becomes a straight line and the EMA of “y” along becomes a straight line. So there will be no buy condition. You can try to change the BUY condition to get better result.. for example ROC(y) > x.

Next let us see the purpose of the peak function. This function tries to ensure that the stock is making a higher high, which is the basic definition of Trend. May be we should check if the stock has already made a higher low. May be this will improve the system a bit.

I did some analysis of your test result. First I really appreciate the big effort. It was must have consumed quite a bit of your time. Looking at results the percentage of green signals is quite high compared to the orange signals. Most orange signals went down later. I wonder what happened to the green ones. Did they go up? If they did then the success rate of the system is quite OK. Of course we cannot have a 100% success rate. Fortunately the red signals are minimal. Overall the system seems to be OK and should given good results with proper MM.

A combination of EMA and ADX could be used to establish the trend. Even better the slope of the EMA line with ADX.. what do you think?

Warm regards

Karthik
Reply With Quote
  #846  
Old 30th March 2007, 09:49 AM
Moderator
 
Join Date: Nov 2005
Posts: 10,249
Thanks: 1,028
Thanked 1,957 Times in 779 Posts
uasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond repute
Reputation: 2033
Default Re: Experiments in Technical Analysis

This is for Ami ,as he posted .

Asish

Last edited by uasish; 4th June 2008 at 09:13 AM.
Reply With Quote
  #847  
Old 30th March 2007, 11:35 AM
Moderator
 
Join Date: Jul 2005
Location: kuwait
Posts: 1,456
Blog Entries: 5
Thanks: 45
Thanked 549 Times in 102 Posts
karthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to allkarthikmarar is a name known to all
Reputation: 629
Default Re: Experiments in Technical Analysis

Asish

Thanks. But it is the same code posted by me. It does looks like a case of name confusion..

regards
Reply With Quote
  #848  
Old 30th March 2007, 03:52 PM
Moderator
 
Join Date: Nov 2005
Posts: 10,249
Thanks: 1,028
Thanked 1,957 Times in 779 Posts
uasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond reputeuasish has a reputation beyond repute
Reputation: 2033
Default Re: Experiments in Technical Analysis

Sorry,age is cathing up.

Asish
Reply With Quote
  #849  
Old 31st March 2007, 09:08 PM
Member
 
Join Date: Dec 2005
Location: Hyderabad
Posts: 326
Thanks: 0
Thanked 1 Time in 1 Post
asnavale is on a distinguished road
Reputation: 30
Default Re: Experiments in Technical Analysis

CONTINUING WITH MACD

Hello friends,

In my earlier post had promised to post the Zero Lag MACD. I had prepared the write-up a few days back. Generally, I show my important write-ups to my friends for their comments before posting. When I showed the Zero Lag MACD write-up to them, they were of the opinion that I should first go into the details of MA lag and methods of removing the lag so that it helps in understanding the Zero Lag MACD. Therefore, I had to revise the write-up and there was delay. Now I am going into the details of MA lag.

MACD is made of two moving averages - one long period Exponential Moving Average and one short period Exponential Moving Average (EMA). The signal line is also a Moving Average. Although there are three EMAs we actually plot two of them, The difference of Short and Long EMAs as MACD line and the EMA as SIGNAL line. As MACD is based on Moving Averages, the advantages and disadvantages of Moving averages are also reflected in MACD. Therefore it is advantageous to study the properties of Moving Averages a little deeper.

Any trader learning Technical Analysis (TA) is first introduced to Moving Averages. Moving averages can be considered as the foundation of Technical Analysis. Two important characteristics of Moving averages are:
  • They smooth the data
  • They lag the data in showing peaks and troughs

Therefore, although the MAs are simple to calculate and interpret, their application is always a trade off between the above two characteristics. If we try to smooth the data more, the lag is also more and vice versa. Smoothening the data means reducing the high variations or filtering the noise. (Those who are familiar with Electrical/Electronics Engineering can consider this as a low pass filter).

The Moving Average Lag is most important characteristic which affects the traders. To reduce/remove this lag we should understand how the lag is introduced. I am explaining this with the help of attached Example-7. In this figure the black dots represent closing price of an Imaginary Stock. For the sake of simplifying the explanation we assume that the data is uniformly increasing or decreasing. That means the difference between two consecutive points is equal throughout. To calculate Simple Moving Average (SMA) for a given period 'p' at any given point we add the current value and all the PREVIOUS (p-1) values and divide the sum by 'p' and put the resulting average value under the current point (The gray colored points in Example-7). We do it for each point in the data set and join the resulting average points to get the Moving Average line. Now look at this process in a different way with the help of the Example-7. Draw a rectangle on the graph such that the current point is on the right end of the rectangle and the previous (p-1)th point is on the left end. The width of rectangle is the period 'p' of averaging. To calculate MA for each day we go on shifting this rectangle to the right one point (or price bar) at a time.

As the points are equally spaced the Average of the points included in the rectangle will be at the center of the rectangle. But we plot this average under the current point. That means we shift it horizontally from the center to the right edge of the rectangle without changing the vertical position. Therefore the shift is equal to half of the width. This shifting is nothing but the Lag of the MA. In other words the Lag is equal to half of the averaging period.

There are two ways to reduce this lag. The first is to produce an equal lag in opposite direction and add to the present lag. Opposite lag can be produced by taking the MA from right to left. That is start calculating the MA starting from latest bar and go towards previous bars. For example, to calculate today's 10-day MA, we add today's price and the prices of next 9 days. This needs future bars which are not available. So this method does not work.

Another way is as follows. Produce another MA with a lag double that of the present lag. So, If we have MA which gives a lag of 'L' days, we take MA which produces a lag of '2L' days. As lag is half of averaging period, the second MA has a period double that of first MA. This is shown in attached Example-8.

Now take difference of the two MAs and add the difference to the shorter period MA. The result is Zero Lag MA.

Code:
Short period MA gives Lag = L
Long period MA gives Lag  = 2L
Difference in the Lags = L - 2L = (-L)
Add this to first Lag = L + (-L) = L - L
Total Lag = L - L = 0
The result of this calculation is shown in attached Example-9. In this figure the dashed line is MA and the continuous line is Zero Lag MA (ZLMA). We can see how nicely the Zero Lag MA fits the price chart. Only at the peaks and troughs the ZLMA deviates from the price line for a short distance and then again merges with the price.

For EMA also the same strategy can be adopted to produce Zero Lag EMA (ZLEMA). In the next post I will deal with the construction of Zero Lag MACD.

Regards

-Anant
Attached Images
File Type: png Example-7.PNG (9.6 KB, 89 views)
File Type: png Example-8.PNG (10.6 KB, 61 views)
File Type: png Example-9.PNG (11.6 KB, 65 views)
Reply With Quote
  #850  
Old 4th April 2007, 03:48 PM
Member
 
Join Date: Sep 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
indrag91 is on a distinguished road
Reputation: 20
Default Re: Experiments in Technical Analysis

Quote:
Originally Posted by asnavale View Post
Hi Raj,

The AFL I had attached was for using as an indicator. For Exploring and backtesting you have to change it slightly. I don't know whether you have made the necessary changes. I am attaching the AFL required for Exploring/backtesting with this message. Try this AFL and give your feedback. This AFL has only Buy and Sell codes. There are no separate Short/Cover codes. Short is same as Sell and Cover is same as Buy.

Note that the attached file has .txt extension which should be changed to .afl before using in AmiBroker.

To use the AFL to include MACD also, set the MACD selection switch appropriately in Exploration window parameters before running Exploration/Back testing.

It is possible to add The price to the charts but it works only in AmiBroker version 4.8 and higher. Therefore I did not add the code so that users with lower versions can also use it. I can give you the additional code also but please let me know which price you want to display? Is it Open or Close or any other?
Regards

-Anant
Mr.Anant
Thanks for ur reply, I downloaded the file and tried backtesting it, but again i found a blank report. I have attached the report here, please guide me where i am wrong.
Raj
Attached Files
File Type: doc MACD BACKTEST REPORT.doc (37.0 KB, 48 views)
Reply With Quote
Sponsored Links

Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads for: Experiments in Technical Analysis
Thread Thread Starter Forum Replies Last Post
Technical Analysis Course snowy Technical Analysis 28 7th November 2008 07:37 PM
Technical analysis course sh50 Seminars & Tutors 18 10th June 2007 03:46 PM
Hello everybody.Technical Analysis vijay chauhan Introductions 2 30th May 2007 03:09 PM
Technical Analysis crosscurrency Forex 0 30th October 2005 11:00 PM


All times are GMT +5.5. The time now is 07:50 AM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you indicate your acceptance of our Forum Rules Disclaimer & Disclosure and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of this information.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2008, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com