Experiments in Technical Analysis

Hi karthik,

another question for u :)..,.i have an oscillator...how do i change the colours for the two lines I will get.

the indicator is as follows
((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)))*10;
(Mov((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)),13,E))*10;0;

I want green colour for the 1st line, red for second and for 0 horizontal line maybe a blue line....is it possible...please let me knwo how to specify colours in the indicator formulae itself.

Rgds

Rahul
 

SGM

Active Member
Hi Karthikmarar,
I have gone thourgh your trading system - "MABIUTS". It is really amazing and would definitely give profitable results. I have done some kind of back testing as well.

In MABIUTS, I understood the concept of 13, 9 EMA. But I failed to understand this condition - C>Peak(1,C,2) mentioned in your pdf file. I think this condition is make sure whether the market is in trending or whipsaw mode.

Could you please explain me what does C>Peak(1,C,2) mean? (I know this sounds very stupid of me)

I don't use MetaStock or Amibroker for Trading so I am not able to used the scripts that you had attached. (See I am so very unfortunate :()

Thanks in Advance...

Regards,
a$h.investor
Hello Ash

The question you have asked was asked by rahul previously and answered by Karthik in the thread. I am quoting them both for all who missed it.

Hi Can anyone explain me the condition

Buy=EMA(C,13)>EMA(EMA(C,13),9) AND Cross (C,Peak(C,5,1));.

So we buy when EMA of 13 crosses above its smoothened avg of 9 days. But what does this condition cross(c,peak(c,5,1)) imply.

Rgds

Rahul
Hi Rahul

It just means that the stock is making a higher high... the close today is greater then the last peak...

warm regards

karthik
Its kinndof crossover with Darvos Box. cross(c,peak(c,5,1)) condition ensures that the buy signal is given only after a breakout, thus giving lesser wipsaws but fewer signals also

You can consider the EMA crossover as the setup (get ready to buy signal) and the cross(c,peak(c,5,1)) as entry.

Happy Trading
Regards
Sanjay
 
Last edited:

SGM

Active Member
Hi karthik,

another question for u :)..,.i have an oscillator...how do i change the colours for the two lines I will get.

the indicator is as follows
((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)))*10;
(Mov((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)),13,E))*10;0;

I want green colour for the 1st line, red for second and for 0 horizontal line maybe a blue line....is it possible...please let me knwo how to specify colours in the indicator formulae itself.

Rgds

Rahul
Hello Rahul

Is this what u want?

Regards
Sanjay

_SECTION_BEGIN("Cost_indi_01");
x=((MA(Close,3)+MA(Close,5)+
MA(Close,8)+MA(Close,10)+
MA(Close,12)+MA(Close,15))-
(MA(Close,30)+MA(Close,35)+
MA(Close,40)+MA(Close,45)+
MA(Close,50)+MA(Close,60)))*10;

y=(MA((MA(Close,3)+MA(Close,5)+
MA(Close,8)+MA(Close,10)+
MA(Close,12)+MA(Close,15))-
(MA(Close,30)+MA(Close,35)+
MA(Close,40)+MA(Close,45)+
MA(Close,50)+MA(Close,60)),13))*10;

z=0;

Plot(x,"Short-Long",colorGreen);
Plot(y,"Smooth_Short-Long",colorRed);
Plot(z,"Short-Long",colorBlue);


_SECTION_END();
 

Attachments

Last edited:
Hi sanjay,

thank you. when u say Plot(x,"Short-Long",colorGreen); short-long is just a name or does it also affect the chart in some manner.

Rgds

Rahul
 
Thanks Sanjay / Karthik,

What I conclude from Cross (C,Peak(C,5,1) is that the today's closing price is greater than last 5th days High price. Please correct me if I am wrong or I will lose bigtime.

I am also working on methods to identify whipsaws. Because most of my systems fail to work in whipsaw and giving wrong signals. ADX is a lagging indicator and gives very late indication when most of the EMA golden crossovers have already taken place.

To some extent Chande Momentum Indicator (CMO) is good indicator but it also gives late indication.

Since this forum is full of genius and experienced traders, I am expecting some response on this.

Regards,
a$h.investor
 

SGM

Active Member
Hi sanjay,

thank you. when u say Plot(x,"Short-Long",colorGreen); short-long is just a name or does it also affect the chart in some manner.

Rgds

Rahul
You are right Rahul, its just a name, any will do. The oscillator is bascially difference between short-term averages and long(er) term averages, thats why i used the name short minus long.

You could also try using EMAs, instead of simple averages.

Regards
Sanjay
 

SGM

Active Member
I am also working on methods to identify whipsaws. Because most of my systems fail to work in whipsaw and giving wrong signals. ADX is a lagging indicator and gives very late indication when most of the EMA golden crossovers have already taken place.
To some extent Chande Momentum Indicator (CMO) is good indicator but it also gives late indication.
Hello Ash

Ashish (acatrader) and Karthik has discussed the use of ADX in the thread, I would suggest you to read thru so u r doubts will be cleared.

Karthik has discussed using Ravi for trend detection and more recently explained the use of and given afls for an better indicator called R2.

Read thru the thread and if you still have queries plz feel free to ask.
What I conclude from Cross (C,Peak(C,5,1) is that the today's closing price is greater than last 5th days High price. Please correct me if I am wrong or I will lose bigtime.
You almost got it right. its not the 5th day high, its the last peak.
AB documentation describes it as follows
SYNTAX: peak(ARRAY, change, n = 1)
RETURNS: ARRAY
FUNCTION: Gives the value of ARRAY n-th peak(s) ago. This uses the Zig Zag function (see Zig Zag) to determine the peaks. n =1 would return the value of the most recent peak. n =2 would return the value of the 2nd most recent peak.

http://www.amibroker.com/guide/afl/afl_view.php?name=PEAK

The parameter change, or the number 5 is /* peak detection threshold */
Plz don't ask me what it means right away, I will tell you as soon as I find out :)

Regards
Sanjay
 
Last edited:
Hi Murthy,

Thank you for your review. It is always helpful to record the views as soon as possible. At the outset I would say that your points were not at all hurting nor discurtious. Let me answer the points:

.

The stocks selected happen to be as per your criteria. May be it was by chance that stocks should be avoided were not selected. In case such a thing happened I would have rejected them. Random selection does not mean take any thing. We can put a precondition to include the selected item. This is one of the reasons I avoided BSE stocks. The BSE list is much larger and the chances of selecting wrong stocks is higher.

Data purity is indeed important. In another thread by Karthik, Database for AMIBROKER, you have stressed this point and given details of using the purify database option. You may remember that I had mentioned there that it helped me detect faulty data.



This is where the NVS comes. In some cases, especially, in down trend there are such occurrences of NVS. This somply means the strategy keeps us out of market, no harm in it. As far as comparison is concerned, it better to be out rather than make loss. However, the H variant of MABIUTS gives least number of such NVS.



I agree but I have given reasons.



1) I am at present giving the results for individual stock performans. Allocating a particular amount and trading is part of portfolio testing which would be presnted later in the series.

2)Sanjay has already explained his view on this. The main purpose here is comparison of results.

2) Right from the beginning of my study I had this condition adopted. I always felt I am missing something which needs keeping the number of shares constant. I could not figure out what was missing but still kept the condition. It was only when I started preparing the report it struck me. It is a simple thing, comparison of results with BUY and HOLD strategy against continuous buy and sell. The BUY and Hold comparision, in my opinion, would be more effective if we keep the number of shares traded constant. How small things miss our attention!

Thanks once again for your healthy and constructive comments. Please do keep on posting as soon as you can. It helps me also to make the future posts take care of any missing details.

Thanks to Sanjay for answering some of the points.

Dear Karthik, we are missing you. I can understand how it feels to be away from the thread you started and encouraged others to experiment. Your inputs will be very valuable. Expecting you soon in the forum with your views and guidance.

Regard

-Anant
Dear Anant,

Not to be impatient but when can we have the MABIUTS-H code for our review. I have MS and will be willing to test it as well.

Thanks,
TheTraderMan
 

asnavale

Well-Known Member
Hello friends,

Thanks for your patience. Here are the four strategies and their AFL codes. I am giving some description and explanation followed by the code. Please go through the description and codes also so that any discrepancies which I might have missed may be brought out.

As I was playing around the original code by modifying this parameter or that, I have re-written the Karthik's original code also in a different way. The code is same, only written in different way. This allows me to change the values easily.

The four strategies are:
1. MABIUTS-K: The Karthik's original. That is why I suffix it with K.
2. MABIUTS-X: The Cross Over strategy. The X stands for Cross Over.
3. MABIUTS-M: The strategy based on Mark McRae's technique. M means McRae.
4. MABIUTS-H: The Histogram based strategy. H stands for Histogram. I will explain it in detail.

1. The Original MAIBUTS by Karthik which I named MAIBUTS-K

I need not explain this as enough has been written about this already. The code which I have re-written is:
***************************************************
("MABIUTS-K :::: Karthik's Exploration");
p1=13;p2=9;
X=EMA(C,p1);Y=EMA(X,p2);

Buy=X>Y AND Cross (C,Peak(C,5,1));
Sell=Cross (Y,X);
Bprice=IIf(Buy,Ref(O,1),0); //Buying Price
Sprice=IIf(Sell,Ref(O,1),0); //Selling Price
//Note: the last character in above two lines is zero not O.

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );

//The following line may be commented out if testing a single stock
AddTextColumn( Name(), "Symbol", 20 , colorDefault);

AddColumn(ref(DateTime(),1), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorWhite, bkcolor =IIf (Buy,colorGreen, colorRed ));

AddColumn(Bprice,"Buy Price",6.2,colorGreen);
AddColumn(Sprice,"Sell Price",6.2,colorRed);
*******************************************************

2. The MABIUTS - X Strategy:

In the MABIUTS-X Code, I have simply removed the Cross(C,(Peak(C,5,1)) and changed the line to CROSS(X,Y). The code is:

**********************************************
("MABIUTS-X :::: Cross-over Exploration");
p1=13;p2=9;
X=EMA(C,p1);Y=EMA(X,p2);
Buy=Cross(X,Y);
Sell=Cross(Y,X);
Bprice=IIf(Buy,Ref(O,1),0); //Buying Price
Sprice=IIf(Sell,Ref(O,1),0); //Selling Price

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );

//The following line may be commented out if testing a single stock
AddTextColumn( Name(), "Symbol", 20 , colorDefault);

AddColumn( ref(DateTime(),1), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorWhite, bkcolor =IIf (Buy,colorGreen, colorRed ));

AddColumn(Bprice,"Buy Price",6.2,colorGreen);
AddColumn(Sprice,"Sell Price",6.2,colorRed);
***************************************************************

3. MABIUTS-M Strategy:

This is based on Mark McRae's method. Here the cross-over of 5-day EMA of Close and 6-day EMA of Open are used. If the EMA(C,5) goes above EMA(O,6) it is buy and when it goes below it is Sell. I will write more about this later. The code is:
*******************************************************
("MABIUTS-M :::: Mark MacRae's method.");
p1=5;p2=6;
X=EMA(C,p1);Y=EMA(O,p2);
Buy=Cross(X,Y);
Sell=Cross(Y,X);
Bprice=IIf(Buy,Ref(O,1),0); //Buying Price
Sprice=IIf(Sell,Ref(O,1),0); //Selling Price

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );

AddTextColumn( Name(), "Symbol", 20, colorDefault);
AddColumn( ref(DateTime(),1), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorDefault, bkcolor =IIf (Buy,colorGreen, colorRed ));
AddColumn(Bprice,"Buying Price",6.2,ColorGreen);
AddColumn(Sprice,"Selling Price",6.2,ColorRed);
***********************************************************

4. MABIUTS-H Strategy:

This is what most people are waiting for. But it needs some explanation. Not because it is complicated. The code is as simple as the others. This is a modification of the Cross Over strategy, MABIUTS-X. What I have done is look at the cross over from a different angle. Any crossover method based on Moving Averages gives the signal after a delay. This is because the Moving Averages are lagging indicators. The delay can be upto half the period of Moving Average. This can be proved. If any of you want the proof, please post a message. I will explain it. It is simple.

Now let us study the cross over from my angle. When two curves cross over what happens is they start coming closer and at the cross over point they meet. Thereafter they move away. If one more cross over occurs they have to come closer again and meet. It means, between the two cross over points they initially go apart upto some distance and then come closer. Put in a different way, the difference between the two moving averages after a cross over goes on increasing, reaches a maximum and then starts decreasing till the cross over. At cross over point the difference is zero. Now, if we plot this difference as a bar graph we get a histogram similar to the MACD histogram. The tallest bar is the maximum point. So, I tried to trade with this maximum bar. When the maximum bar appears SELL and when it is minimum (NOT ZERO) SELL. It worked wonders. It was able to catch the trend change and price reversals very early compared to the Cross over.
To identify the maximum and minimum bars you can plot this difference as histogram and visually see. You can explore and locate the bars by writing a code to identify the max and min. How do we do it? A maximum bar is identified by two smaller bars on either side. So among three consecutive bars, if the middle bar is the highest you have the maximum. Similarly Among three consecutive bars if the middle bar is the shortest then you have the minimum. This is what I have coded in the MAIBUTS-H. The Code is:
*********************************************************
("MABIUTS-H :::: Histogram Exploration");
p1=15;p2=15;
X=EMA(C,p1);Y=EMA(X,p2);
D=X-Y;

Buy=Ref(D,-2)>Ref(D,-1) AND D>Ref(D,-1);
Sell=Ref(D,-2)<Ref(D,-1) AND D<Ref(D,-1);
Bprice=IIf(Buy,O,0); //Buying Price
Sprice=IIf(Sell,O,0); //Selling Price

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );
//The following line may be commented out if testing a single stock
AddTextColumn( Name(), "Symbol", 77 , colorDefault);

AddColumn( Ref(DateTime(),1), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorWhite, bkcolor =IIf (Buy,colorGreen, colorRed ));
AddColumn(Bprice,"Buying Price",6.2,colorGreen);
AddColumn(Sprice,"Selling Price",6.2,colorRed);
**********************************************************

I wanted to discuss these four strategies in more detail. But I have some other urgent work. Therefore I am not giving any results today. As many of you are waiting eagerly for these codes I decided to just give them and postpone the discussion to another post. I know you have many questions but I will answer them later. But post your queries, views and comments at the earliest so that you won't forget any points.

Sorry for very brief description.

As I have written this in a hurry, there may be some grammatical or spelling mistakes. I did not check. Please ignore them. If there are any errors in the program, pleasae bring to my notice.

Regards.

-Anant
 
Last edited:

Similar threads