Registered User Joined: 2/27/2005 Posts: 15 
	 | 
	
		Can you please help me write Real Code that will allow me to identify all stocks that are within 25% of thier all time high? 
 
 
Thanks!
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		Keeping in mind that an "all time high" can only be calculated versus the data used as set under Settings | Data Manager, you might want to try something similar to the following RealCode Rule: 
 
'# Cumulative 
Static ATH As Single 
If isFirstBar Then 
    ATH = Price.High 
Else 
    If Price.High >= ATH Then 
        ATH = Price.High 
    End If 
End If 
If Price.Last / ATH >= .75 Then Pass
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 9/18/2009 Posts: 60 
	 | 
	
		I pulled this oldie but goodie up.   Is there an adaption to this where we can find all stocks that are within 25% of its 5 year high and which works for young stocks like ISLN? 
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		You could try something like the following: 
 
'|*****************************************************************| 
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com  
'|*** Copy and paste this header and code into StockFinder ********* 
'|*** Condition:Within Percent of High 
'|****************************************************************** 
'# Period = UserInput.Integer = 1260 
'# Percent = UserInput.single = 25 
'# Cumulative 
Static Ratio As Single 
If isFirstBar Then 
    Ratio = 1 - Percent / 100 
End If 
If Price.Last >= Price.MaxHigh(System.Math.Min(Period, CurrentIndex)) * Ratio Then 
    Pass 
End If
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 9/18/2009 Posts: 60 
	 | 
	
		 Bruce,  
 
Thank you.   I played around with your program and using your CurrentIndex I came up with a different method: 
 
15% of 5 year High On Weekly Chart 
  
'# Cumulative 
If Price.Last / Price.MaxHigh(System.Math.Min(260, CurrentIndex)) > .85 Then 
            Pass 
End If 
  
  
  
'# Cumulative 
If Price.Last / price.MaxHigh(currentindex) > 0.85 
            Pass 
End If 
 
Its seems to work. 
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		There's no reason it shouldn't work. The math is the same albeit with different settings and the MaxHigh moved to the other side of the inequality. It just isn't adjustable because it doesn't have User Inputs for the settings. 
 
It could probably be sped up some by using the algorithm from my Tuesday, June 16, 2009 8:38:36 AM ET post for the early Bars and switching to Price.MaxHigh once there are enough Bars available.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 9/18/2009 Posts: 60 
	 | 
	
		 ......early Bars and switching to Price.MaxHigh once there are enough Bars available .....    
 
Ahhh, so that is what you were doing.  I couldn't figure out that part.    I haven't noticed any slowness when I flip through the charts with or without those Real Codes.     Thank you for reviewing my work. 
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		You're welcome. I'm happy to read your current solution is quick enough.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Could you please help me write Real Code that will allow me to identify all stocks that are about to reach (25%) of his all time high? 
 
 
Thanks!
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		bartolo, 
We cannot generally create Conditions to identify what will happen, only what has happened. 
 
My Tuesday, June 16, 2009 8:38:36 AM ET post has a RealCode Condition for identifying symbols that are within 25% of their "all time high" (at least based on the available data being used). 
 
If you have specific unambiguous objective criteria which you believe are indicative of a symbol that is about to reach 25% of its all time high, we may be able to create a Condition for those criteria.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Sorry 
I will try to explain with an example of CBE Cooper Industries, is a stock wich his All time High is on 7/31/2007 (monthly chart) in 59,05 this month high is 54,48 therefore it will take a 8.4% to reach its all time high. 
I would like if it is possible to find all stocks that are for example at a 5%, 10% or 8,4% (like in this example) about to reach its all time high. 
Thank you
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		bartolo, 
As stated previously, my Tuesday, June 16, 2009 8:38:36 AM ET post already has a RealCode Condition  for identifying symbols that are within 25% of their "all time high" (at  least based on the available data being used). 
 
If you want the Percentage to be adjustable, you could use something like the following instead: 
 
'|*****************************************************************| 
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com  
'|*** Copy and paste this header and code into StockFinder ********* 
'|*** Condition:Near All Time High 
'|****************************************************************** 
'# Percent = UserInput.Single = 25 
'# Cumulative 
Static ATH As Single 
Static Ratio As Single 
If isFirstBar Then 
    ATH = Price.High 
    Ratio = 1 - Percent / 100 
Else 
    If Price.High >= ATH Then 
        ATH = Price.High 
    End If 
End If 
If Price.Last / ATH >= Ratio Then Pass 
 
If you want the Percent to be based on the current Price instead of the All Time High, you could reverse the Ratio: 
 
'|*****************************************************************| 
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com  
'|*** Copy and paste this header and code into StockFinder ********* 
'|*** Condition:Near All Time High 
'|****************************************************************** 
'# Percent = UserInput.Single = 25 
'# Cumulative 
Static ATH As Single 
Static Ratio As Single 
If isFirstBar Then 
    ATH = Price.High 
    Ratio = 1 + Percent / 100 
Else 
    If Price.High >= ATH Then 
        ATH = Price.High 
    End If 
End If 
If ATH / Price.Last <= Ratio Then Pass
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Thank you Bruce 
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		bartolo, 
You're welcome.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Hello Bruce 
Could you Write me (same as above) a RealCode Condition for identifying symbols that are within 25% (adjustable), of their "All time Low" . 
And volume bigger than 1.000.000$ (adjustable), (dollars instead of shares). 
Thank you very much.
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		'|*****************************************************************| 
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder ********* 
'|*** Condition:Near All Time Low 
'|****************************************************************** 
'# Percent = UserInput.Single = 25 
'# MinDolVol = UserInput.Single = 1000000 
'# Cumulative 
Static ATL As Single 
Static Ratio As Single 
If isFirstBar Then 
    ATL = Price.Low 
    Ratio = 1 + Percent / 100 
Else 
    If Price.High < ATL Then 
        ATL = Price.Low 
    End If 
End If 
If Price.Last / ATL <= Ratio AndAlso _ 
    100 * Volume.Value * Price.Last > MinDolVol Then Pass
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Thank you
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		 Bruce 
I copy and paste the formula and gave me some errors, could you tell me whats wrong 
Thank you very much 
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		Certainly not without you providing the error messages you are receiving as the RealCode as posted does not produce any error messages on my computer.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
	
	
	
		Registered User Joined: 11/4/2010 Posts: 7 
	 | 
	
		Sorry I did something wrong. 
Thank you very much
	 | 
	 | 
	
	
	
		 
   Worden Trainer
  Joined: 10/7/2004 Posts: 65,138 
	 | 
	
		You're welcome. I'm happy to read you were able to figure it out.
  -Bruce Personal Criteria Formulas TC2000 Support Articles
	 | 
	 | 
| 
Guest-1 |