Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 10/10/2007 Posts: 22
|
would like a real code for price crossing yesterdays closing price (up or down)
Thanks,
Joe
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 710
|
fowlie48
Try this:
If price.close(1) > price.low And price.last > price.close(1) Or price.close(1) < price.high And price.last < price.close(1) Then pass
|
|
Registered User Joined: 10/10/2007 Posts: 22
|
Michael T, That works for the Daily chart. However... I'm interested in The hourly and 5 min chart crossing yesterday's close.
Thanks,
Joe
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
This should do it. Will work on any time frame and return True when price crosses up or down through the previous day's close.
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.1 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price crossing prev day close
'|*** Example: if price.percentChange > 1 then pass
'|******************************************************************
Static prevDayClose As Single
Static prevDay As Single
If isFirstBar Then
prevDay = price.DateValue().day
End If
Dim currDay As Integer = price.DateValue().day
If currDay <> prevDay Then
prevDay = currDay
prevDayClose = price.close(1)
End If
If prevDayClose > 0 Then
If (price.close(1) < prevDayClose And price.close > prevDayClose) Or _
(price.close(1) > prevDayClose And price.close < prevDayClose) Then pass
End If
|
|
Registered User Joined: 10/10/2007 Posts: 22
|
I could not get it to work. I just cut and paste into new real code condition.
Joe
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
If you copy the header through End If, you can just right-click on the chart in StockFinder and select Paste.
After you create the condtion, right click on the condition and Paint Price History so you can see where it's returning True. Make sure your chart is set to an intraday time frame.
|
|
Registered User Joined: 10/10/2007 Posts: 22
|
It paints fine, however when I use it as a sort it brings back all symbols indicating greater than 50 bars. This is on a 5 minute time frame.
Joe
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
That means that none crossed the previous days price in the last 50 bars which would have been since around 11:50am on July 1. I just spot-checked about 100 symbols and none of them crossed over the previous day's close since early in the trading day on Friday.
|
|
Registered User Joined: 10/10/2007 Posts: 22
|
thanks, your right.
|
|
Guest-1 |