Registered User Joined: 2/14/2006 Posts: 117
|
I am looking to find any of of the following situations.
1. On a 60 minute chart, any of the 7 candles is a Doji, Hammer(High and Close equal) or a engulfing (High and Close equal and Low and Open equal).
2. Secondly, I need to be able to retain the stock after the stock has met any of the above 3 criteria. What I mean is this. Say I run this scan at 9.30 am and if the first candle meets any of the criteria, the scan will capture it. And if the second candle does not meet any of the 3 criteria, the stock that qualified at 9.30 will disappear from the scan if I run it at 10.30am. But I need it to be able to retain the stock that qualified at 9.30am until end of the day.
3. I also need to be able to scan using the same criteria on any given past date ie yesterday, 2 days ago or 3 days ago.
Thanks in advance.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Assuming a Doji is the Open and Close equal and your Hammer and Engulfing are as you describe and both need to have their High and Close equal, you could try something similar to the following RealCode Condition:
Static TrueForDay As Boolean
Static Valid As Boolean
If isFirstBar
Valid = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Price.Open = Price.Last OrElse _
Price.High = Price.Last Then
TrueForDay = True
End If
If Valid = True Then
If TrueForDay = True Then
Pass
End If
Else
SetIndexInvalid
End If
The RealCode Condition is not specific to the hourly bar interval. It should work using any intraday bar interval and test using candles based on the bar interval to which the Condition has been set.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Thanks Bruce. I still need to know how I could run this scan on a given past date.
Thanks
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
Please ignore my post on July 7th and consider the following.
1. When I run the scan you provided I get candles with upper shadow. Doji and Hammer seem to work allright. Hence the candle with upper shadow may represent my engulfing which should not have an upper shadow.
2. Secondly, the scan looks for candles that meet my criteria throughout the history. Can I restrict them first to the current day and then to look back at my discretion. That way the number of stocks that come up will be restricted to a few. And those are the ones that can be actioned upon today. Being able to go back to a past date will only help in hindsight.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You could plot the Indicator on the chart or use it in BackScanner to check for past values.
Doji was not defined in your post but I used the open and the close being equal. This is the only circumstance where there should be an upper shadow as you defined your Hammer as the high and close being equal and your Engulfing as the high and close being equal and the low and open being equal. I did not add any additional requirements to your descriptions apart from defining a Doji.
The RealCode Condition only returns true in a WatchList Column for symbols which met your requirements during one of the bars of the current trading day using the bar interval (time frame) selected for the RealCode Condition. If the bar interval of the RealCode Condition is set to hourly, it will only return true for symbols which meet your requirements on an hourly bar during the current trading day.
You can see how this develops by right-clicking on the Condition on the chart and selecting Show True Markers. The Condition will start plotting true at the first bar during the trading day where the open equals the close or the high equals the close and continue plotting true for the rest of the day.
A similar Condition Formula which just plots true on the individual bars which meet your requirements is much shorter and could be written as:
If Price.Open = Price.Last OrElse _
Price.High = Price.Last Then
Pass
End If
Note that both this shorter RealCode Condition and the longer RealCode Condition given above use the bar interval of the Condition for its calculations. The bar interval needs to be set to hourly to test hourly bars. We could make a version which forces an hourly bar interval. Replace everything below the Inherits line in the Class tab of the RealCode Editor for a RealCode Condition with the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Sub CallUserCode()
Dim tf As New HourlyTimeFrameProvider
tf.NumMins = 1
Dim cS As PriceScripting
cS = PriceData(CurrentSymbol, tf)
If cs.Bar.Count > 1 Then
Dim TrueForDay As Boolean = False
Dim Valid As Boolean = False
For i As Integer = 1 To cS.Bar.Count - 1
If cS.Bar.DateValue(i).DayOfYear <> cS.Bar.DateValue(i - 1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Valid = True Then
If cS.Bar.OpenValue(i) = cS.Bar.Value(i) OrElse _
cS.Bar.HighValue(i) = cS.Bar.Value(i) Then
TrueForDay = True
End If
AddToOutput(cS.Bar.DateValue(i), TrueForDay)
End If
Next
End If
End Sub
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
Thanks for your time. I am still not getting what I want. I ran both the short and long versions. They both scan for the entire history. I scanned using hourly candles. I used true markers and they show where the condition has met the criteria. I also noticed that a bubble develops on the watchlist when condition is met during the day and other stocks that do not have a bubble do in fact have met conditions but not today. That is the only difference between stocks with a bubble and stocks without a bubble. So basically, I get past values without ploting the indicator on the chart or running the backscanner.
I do not want to force an hourly bar interval. You are right I did not define a doji but it should as you have said be open and close equal.
Now here is what I need. I will always use it on hourly or 30 minutes charts. First, let us concentrate on only today's candles. As soon as any of the 3 candle condition is met it forms a bubble on the watchlist column. And that bubble will stay for the entire day even if any of the following candles does not meet the criteria.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
QUOTE (nimal) Now here is what I need. I will always use it on hourly or 30 minutes charts. First, let us concentrate on only today's candles. As soon as any of the 3 candle condition is met it forms a bubble on the watchlist column. And that bubble will stay for the entire day even if any of the following candles does not meet the criteria.
As you have noted earlier in your post, that's what already happens.
QUOTE (nimal) I also noticed that a bubble develops on the watchlist when condition is met during the day and other stocks that do not have a bubble do in fact have met conditions but not today.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce
Quote from my prior post
"Now here is what I need. I will always use it on hourly or 30 minutes charts. First, let us concentrate on only today's candles. As soon as any of the 3 candle condition is met it forms a bubble on the watchlist column. And that bubble will stay for the entire day even if any of the following candles does not meet the criteria"
The above does not happen as you say it does. This does happen after hours but not intraday. What actually happens intraday is this. A bubble forms as the condition is being met and then after the candle has completed forming the bubble disappears only to return if and when the condition is met again.
This does not help me at all. I need the the bubble to stay if the completed candle has met any of the conditions. Let us say the first candle is a Doji and the rest of the candles do not meet the criterias but the bubble stays for the entire day because the first candle of the day has met the criteria.
Hope this clarifies what I really need. If I said earlier that it does happen now I confirm that it does not happen.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
So I've been watching this since the market opens in different time frames and once there is a completed bar which meets the requirements, the bubble does not go away on my computer.
The only time there is a bubble that goes away is if the currently forming bar temporarily meets the conditions and there were no prior bars during the trading day which met the requirements.
It is possible to verify this by choosing # True in a Row instead of Sort or Condition Column when dragging and dropping the Condition to the WatchList.
It is possible to create a RealCode Condition which ignores the current bar, but this is problematic at the end and beginning of each day. At the end of each day you would not get a true result if the only bar meeting the requirements is the last bar of the day. At the beginning of each day you would get the results of the previous day until the first bar of the day has finished forming.
If you want to give it a try, please replace everything below the Inherits line in the Class tab of the RealCode Editor of a RealCode Condition with the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Sub CallUserCode()
If Price.Bar.Count > 2 Then
Dim TrueForDay As Boolean = False
Dim Valid As Boolean = False
For i As Integer = 1 To Price.Bar.Count - 2
If Price.Bar.DateValue(i).DayOfYear <> Price.Bar.DateValue(i - 1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Valid = True Then
If Price.Bar.OpenValue(i) = Price.Bar.Value(i) OrElse _
Price.Bar.HighValue(i) = Price.Bar.Value(i) Then
TrueForDay = True
End If
AddToOutput(Price.Bar.DateValue(i), TrueForDay)
End If
Next
End If
End Sub
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
If you can please take a look at symbol RPM right now. It has a Doji and Engulfing both meeting my definitions. But there is no bubble. Hope this will enable you to find what is missing/wrong.
Thanks
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
RPM currently has a bubble when using an hourly bar interval for me.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Then this has to be some other problem. Because I do not have a bubble on hourly chart. TV is one more symbol it has a true marker no bubble.
Nimal
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
WRB is one more with only a true marker.
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
TV and WRB also currently have bubbles when using an hourly bar interval for me.
If the result is true on the chart, it should be true in the WatchList Column as well.
Try dragging and dropping the Condition from the chart to the WatchList Column and select either Sort or Condition Column again to see if that resolves the issue.
You may also want to right-click on the WatchList Column Header so you can check the Update Frequency and Sort Frequency of the WatchList Column. If it is set to too long a time, it may just not be current.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
No it did not resolve the issue. I tried both sort and WL Column and updated the frequency to every tick.
I got to go. Pls see what you can do.
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please contact technical support.
All e-mail communication sent to support@worden.com during business hours (Monday through Friday 9AM-11PM and Saturday and Sunday 9AM-3PM ET) should be answered within 20 minutes of arrival.
For an even quicker response to tech support questions, we recommend calling our voice line at (919) 408-0542 (there is no phone support on Sundays, some Market Holidays or after 9PM ET on weekdays).
You can also contact us using Live Chat Support during business hours.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
I spoke to your tech support and spend almost an hour. He says it is not possible for the bubble to stay because it can only show the candle being formed. This means that as soon as the candle completes the bubble will disappear. He also suggests that I keep the updating frequency to one day and update manually whenever I need during the session. Even then all the bubbles will disappear if I update immediately after the session is over and only if the last candle is a qualifying candle a bubble will remain.
This is contradictory to what you have been saying. I am going to see how it unfolds tommorrow and let you know.
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Are you using the RealCode from my Wednesday, July 11, 2012 10:58:37 AM ET post or the RealCode from my Friday, July 06, 2012 9:06:32 AM ET post?
In both cases, the bubble will remain solid once a candle has completed during the day which meets your requirements.
In the case of the Wednesday, July 11, 2012 10:58:37 AM ET RealCode, it will consider the currently forming bar and a bubble may become solid and the go away if no prior bar during the trading day meets the requirements and the currently forming bar meets the requirements only temporarily.
In the case of the Friday, July 06, 2012 9:06:32 AM ET RealCode, the current bar is not considered at all. Once a bubble is filled during the day it will remain filled in during the day. But while the first bar of the day is still forming, the bubbles will represent the entirety of the previous day. And the last bar of the day will not affect the bubble until the first bar of the next day starts forming.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
I use the following code.
If Price.Open = Price.Last OrElse _
Price.High = Price.Last Then
Pass
End If
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
As my Monday, July 09, 2012 11:22:01 AM ET post where you got it indicates, that RealCode Condition "just plots true on the individual bars which meet your requirements". This does not appear to be what you want.
You probably want to switch to either the RealCode from my Wednesday, July 11, 2012 10:58:37 AM ET post or the RealCode from my Friday, July 06, 2012 9:06:32 AM ET post depending on which behavior described in my Friday, July 13, 2012 8:47:00 AM ET post (as well as in earlier posts) is most desirable.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi
I changed to Friday, July 06, 2012 9:06:32 AM ET post and I have the updating and sorting frequency set to manual for all the wathlist columns. The bubble seems to be holding but when I set true markers on I see True markers for candles that do not meet my definitions of the 3 candles.
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes, that is true and as it should be.
Once a candle meets your requirements during the day, that candle and all of the candles following it during the same day will return true.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
I would appreciate a slight change to the RC Ref July 9, 2012 11:22:01 AM (Short Version) to reflect only a bullish hammer rather than Doji, Hammer and Engulfing.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Your Bullish Hammer definition is very simple in that it only specifies that the high and the close are equal.
If Price.High = Price.Last Then
Pass
End If
This will not somehow prevent symbols where the Open also equals the High and Close or where both the Low and Open and High and Close are also equal returning true.
If you want to make sure that the Open is also near the top of the candle, you could specify the Open be in say the top third of the candle:
If Price.Open = Price.Last AndAlso _
Price.High - Price.Open < (Price.High - Price.Low) / 3 Then
Pass
End If
If you also want to guarantee the Open does not equal the close for some reason, you would need to check for that as well:
If Price.Open = Price.Last AndAlso _
Price.Open <> Price.Last AndAlso _
Price.High - Price.Open < (Price.High - Price.Low) / 3 Then
Pass
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Thanks for the above. Is it possible to make the Force Index to ocsilate between set values ie +100 and -100 with the centre line at Zero. This may sound funny but I just find it hard to scan for a particular value of the Force Index because its values differ from symbol to symbol.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
One way to do this would be determine the maximum absolute value of both net change and volume over some period of time to calculate a maximum theoretical Force Index over the period. Then express the actual Force Index as a percentage of the maximum theoretical Force Index.
You should be able to Open an attached Indicator directly into a running copy of StockFinder 5 (and save it from within StockFinder 5 if desired). You could also Save it to the \My Documents\StockFinder5\(Your Username)\My Indicators\ folder and then load it like you would any other Indicator (or Copy and Paste it there from wherever it Saves if you can't specify the destination directory when Saving).
Attachments: Elder Force Index Normalized.sfInd - 10 KB, downloaded 727 time(s).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
I need a modification to the following real code to include volume surge above a variable moving average. I can create a condition using the in built Volume Surge Indicator but it does not stay static when the bar is complete. So combining the two together I hope will find what I am looking for.
Static TrueForDay As Boolean
Static Valid As Boolean
If isFirstBar
Valid = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Price.high = Price.Last Then
TrueForDay = True
End If
If Valid = True Then
If TrueForDay = True Then
Pass
End If
Else
SetIndexInvalid
End If
Thanks
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Also please change the candle from Bullish Hammer to close higher than or equal to open. I had earlier defined the Bullish Hammer as high and close being equal. So please disregard that definition for this amendment. So this will have a candle with close higher than or equal to open along with the volume surge.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The following adjusts the definition of a Bullish Hammer to the close being at or above the open. It also imports a Volume Surge indicator and allows you to set a minimum threshold for Volume Surge which must also be true to qualify the Bullish Hammer. You can click on the Condition to bring up a window which will allow you to adjust the VSthreshold and Volume Surge settings.
'# VS = indicator.Library.Volume Surge
'# VSthreshold = UserInput.Single = 3
Static TrueForDay As Boolean
Static Valid As Boolean
If isFirstBar
Valid = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Price.Last >= Price.Open AndAlso _
VS.Value >= VSthreshold Then
TrueForDay = True
End If
If Valid = True AndAlso _
Single.IsNaN(VS.Value) = False Then
If TrueForDay = True Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi Bruce,
I cannot set a minimum threshold for the Volume Surge. When I click on the condition I get a window which only shows "Of the last --- Passing---. Am I doing some thing wrong.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I somehow post a preliminary version of the RealCode instead of the final version. Fortunately the final version was still in my layout so I didn't have to re-write it and I have updated the original response.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Hi,
I am bit confused. What is VSthreshold of 3. Is it the volume surge Moving average. I tried it at 3 and I did not get any symbol. I set it to 1 and got a few using hourly charts. Can you elaborate.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The Volume Surge indicator in StockFinder is simply the ratio of a short term moving average of volume to a long term moving average of volume. By default it would be the ratio of 1-Period Simple Moving Average of Volume (which is just the current Volume Bar) to the 100-Period Simple Moving Average of Volume.
A VSthreshold of 3 in the RealCode Condition would mean the value of the Volume Surge indicator for a bar with its close higher than its open was at least 3. If both requirements are true for a given bar during the day, the rest of the bars during the day will return true as well.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Bruce,
Can you please amend the code dated"August 28, 2012 4:29:24 PM" to reflect the following.
Instead of volume surge I want to use the volume with a moving average that can be varied by user. And secondly, candle close has to be greater than open. Both the conditions need to be satisfied simultaneously.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I've adjusted the RealCode to use a simple moving average of volume instead of volume surge and the volume surge threshold was changed to a minimum average volume. The rest of the RealCode and its behavior should remain the same.
'# Period = UserInput.Integer = 50
'# MinVolume = UserInput.Single = 1000
Static TrueForDay As Boolean
Static Valid(1) As Boolean
If isFirstBar
Valid(0) = False
Valid(1) = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
TrueForDay = False
End If
If CurrentIndex >= Period Then
Valid(1) = True
If Price.Last >= Price.Open AndAlso _
Volume.AVG(Period) >= MinVolume Then
TrueForDay = True
End If
End If
If Valid(0) = True AndAlso _
Valid(1) = True Then
If TrueForDay = True Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
Bruce,
Thanks for the change . This code takes a very long time to calculate making it almost useless. I would like to input just the volume moving average period ie 21 days, 40 days etc and NOT the minimum Volume. It might even make the code more efficient?. Can you please effect that change.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It is a Condition. It's components need to return true or false. Volume returns a numeric value instead of being true or false. You need to make some sort of comparison in order for the volume to get converted to a true or false result which can be used in the Condition.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/14/2006 Posts: 117
|
I have tried to use it in a number of ways and it is very very slow. An I do not want to use it the way it is. I would like to use it with a variable moving average of volume ie 21 days rather than with a variable absolute value such as 1 Ml shares.
So please make the average variable by user if possible. It will pick whatever volume applicable to that average. If it is not logically possible to do so just forget about it.
Nimal
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Volume.AVG(21)
Just returns the 21-Period Simple Moving Average of Volume. It does not return true or false. You need to compare it to something to get a true or false result. For example, the following would check for the current volume to be greater than the 21-Period Simple Moving Average of Volume:
If Volume.Value > Volume.AVG(21) Then Pass
Note that this is exactly the same as:
'# VS = indicator.Library.Volume Surge
'# VSthreshold = UserInput.Single = 1
If VS.Value > VSthreshold Then Pass
When the short period is the Volume Surge indicator is set to 1 and the long period in the Volume Surge indicator is set to 21. We could make this comparison and get the following RealCode Indicator, but we cannot just add the moving average of volume with making a comparison of some sort to something.
'# Period = UserInput.Integer = 21
Static TrueForDay As Boolean
Static Valid As Boolean
If isFirstBar
Valid = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
TrueForDay = False
Valid = True
End If
If Price.Last >= Price.Open AndAlso _
Volume.Value >= Volume.AVG(Period) Then
TrueForDay = True
End If
If Valid = True AndAlso _
CurrentIndex > Period Then
If TrueForDay = True Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |