

MetaStock System Test 01  R2, S/C, MFI (Vol Required) 


The RSquared, S/C,MFI test is based on linearregression. RSquared is a linear
regression function that measures how stronga data array of given length is trending. It's really based on correlation.A return of one correlates to a very strong trend in either direction thatrises or falls one point per day. A return of zero correlates to no trend.
I'm using RSquared to tell me when there is no trend over the last 21 days, or that RSquared(C,21) is less than 0.15. Now that we have no trend, wewould expect one to start in the next 5 to 13 days. If one does start wewant to determine the direction and get in early. Therefore I use RSquaredas mytrigger, combining it with the ALERT function. With the ALERT givenby RSquaredbeing less then 0.15, then we will get a buy signal if all myother conditionsare met within a 13day period that I also set with theALERT function. Forthe other conditions, I'm using S/C, MFI, and the 55dayVariable Moving Average (vma) to determine trend start and direction.
S/C is nothing more than the normalized 34 day LinRegSlope of the close. I normalize it by dividing it by the close so charts are more directly comparable. I also multiply by 10000 just to get numbers between 0 and a few hundred. Finally I apply Tema smoothing to get a smoother plot.
Therefore my formula for Tema S/C becomes:


Tema S/C
Periods := Input("Enter Periods",1,233,34);
Tema(10000*LinRegSlope(C,Periods)/C,Periods)


The theory is that if Tema S/C is rising then a up trend is in progress. If Tema S/C is falling a downtrend is in progress. I check this by making sure that tema(S/C) is larger than an optimized value (opt1) and is rising. I use the function HHV(X,5) = HHV(X,13) to check that it is really rising. This is just a quick way to determine if the most reason values of X have been rising. If the condition is met, then S/C is rising. Similarly if it met the condition LLV(X,5) = LLV(C,13) it would be falling.
I doublecheck the result by also making sure that both the MFI and the 55day vma are also rising. I use a Tema MFI formula which is just the tema smoothed MFI  50 so it can be plotted as a histogram. The formula is: 

Tema MFI
Periods := Input("Enter Tema Smoothing Periods",13,55,55);
Tema(MFI(Periods),Periods)  50


When all conditions are met within 13 days of the alert, we get a buy signal. The converse is true for a sell signal. Since the market is biased upwards, I use an additional check for the short  Tema MFI less then 0. I closethe positions when the trend has stopped. For the long position I checkthatthe Tema(MFI) is below 0, the Tema(S/C) is below opt 1 and that bothare falling. Short positions tend to move faster, so I only look for theTema MFI to be greater than zero and the 55 day vma to begin rising to closethat position. The complete test follows: 

MetaStock System Test 01 R2,S/C,MFI (VolRequired)
Enter Long :
Alert(RSquared(C,21) < 0.15,13) AND
Tema(10000*LinRegSlope(C,34)/C,34) > opt1 AND
HHV(Tema(10000*LinRegSlope(C,34)/C,34),5) =
HHV(Tema(10000*LinRegSlope(C,34)/C,34),13) AND
HHV(Tema(MFI(55),55),5) = HHV(Tema(MFI(55),55),13)
Close Long :
Tema(MFI(55),55)  50 < 0 AND
Tema(10000*LinRegSlope(C,34)/C,34) < opt1 AND
LLV(Tema(10000*LinRegSlope(C,34)/C,34),5) =
LLV(Tema(10000*LinRegSlope(C,34)/C,34),13) AND
LLV(Tema(MFI(55),55),5) = LLV(Tema(MFI(55),55),1)
Enter Short :
Alert(RSquared(C,21) < 0.15,13) AND
Tema(10000*LinRegSlope(C,34)/C,34) < opt2 AND
LLV(Tema(10000*LinRegSlope(C,34)/C,34),5) =
LLV(Tema(10000*LinRegSlope(C,34)/C,34),13) AND
LLV(Tema(MFI(55),55),5) = LLV(Tema(MFI(55),55),13) AND
Tema(MFI(55),55)  50 < 0 AND
LLV(Mov(C,55,VAR),5) = LLV(Mov(C,55,VAR),13)
Close Short :
HHV(Mov(C,55,VAR),5) = HHV(Mov(C,55,VAR),13) AND
Tema(MFI(55),55)  50 > 0
OPTIMIZATION:
OPT1: Min=34 Max=8 Step=13
OPT2: Min=55 Max=21 Step=34




Although I have Tema S/C and Tema MFI defined as custom formulas so I can plot them as indicators on my charts, I don't call the custom formulas in the tests. Instead I use the actual formulas. The reason I do this, is that the test will run faster when the formulas are used direct instead of calling for the custom formulas.
from Jim Greening http://www.geocities.com/ 

Source / From: 
TOP 
http://www.guppytraders.com 

