log in     sign up for free
 
Your worst-case exit, which is designed to preserve your capital, should be determined ahead of time.
Van K. Tharp
 
 
Home
systems (285)
 
 
Special offer: buy AmiBroker and EOD+Real-Time Data
 

Buy

AmiBroker

     (special offer)
 
 
 

Buy

EOD data for AmiBroker

     (special offer)
 
 
 

Buy

Realtime data for AmiBroker

     (special offer)
 
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

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

System for: MetaStock

 

 

Views:  2072

Added: February 09, 2007
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 
 

email this link

 
 
Tags: MetaStock, system
 


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 13-day period that I also set with theALERT function. Forthe other conditions, I'm using S/C, MFI, and the 55-dayVariable 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 double-check the result by also making sure that both the MFI and the 55-day 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/

 

 



Code:

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






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





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


 




 

Code to difficult? Find somebody to help you with coding here.

 


Source: http://www.guppytraders.com

 

View similar:

MACD Crossover System Test
Threshold Trading Revisited - RSI

Commodity Channel Index Buy & Sell Signal
Historical Volatility Trading System
J2L Trading System
Pivot Points & Volume
MA Cross System
Bull Fear/Bear Fear with DX System
Candle - 3 Crows & Soldiers & %D
...
 
 
all systems for MetaStock
all systems

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
PayPalSecure payments by PayPal S4T™ is a part of TAURO EDUCATION NETWORK
 
Privacy note | (c) copyrights systems4trading.com 2006-2009