Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

yesterday infor.. Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
shcorp886
Posted : Friday, June 7, 2013 1:32:15 PM
Registered User
Joined: 11/4/2009
Posts: 81

hi Bruce,

can you help me to write the realcode for an indicator or the BLOCK

30 minutes chart or 5 minutes chart

i like to plot the constant number of yesterday ending value of one indicator on my chart.

for example, 5 minutes chart, 20 moving average, the value of yesterday ending for the ma is 1600, i want to plot 1600 through  today range on 5 minutes chart; if day before yesterday ma value is 1606 then plot 1606 through the whole day of yesterday, so on..

 

allen

 

Bruce_L
Posted : Friday, June 7, 2013 2:03:18 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

The first line of the following RealCode Indicator was created by dragging and dropping the indicator of interest into the Code tab of the RealCode Editor for a RealCode Indicator. Note that the variable name automatically assigned when doing so might be different than MA. If it is, then you need to make sure that the second reference to MA in the RealCode uses the same variable name as well. For example, if it were RSI, then later on in the code, you would need YestValue = RSI.Value instead of YestValue = MA.Value.

RealCode for Real People: Indicators

'# MA = chart.MovingAverage
Static YestValue As Single
If isFirstBar Then
	YestValue = Single.NaN
Else If Price.DateValue.Day <> Price.DateValue(1).Day Then
	YestValue = MA.Value(1)
End If
Plot = YestValue


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
shcorp886
Posted : Friday, June 7, 2013 2:57:46 PM
Registered User
Joined: 11/4/2009
Posts: 81

thank you Bruce,

now i understand the price.datevalue.day <> price.datevalue910.day that gives me the condition of today and yesterday. am i correct?

 

Bruce_L
Posted : Friday, June 7, 2013 3:01:20 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If Price.DateValue.Day <> Price.DateValue(1).Day Then

Checks for the current bar to a different day than the previous bar.

YestValue = MA.Value(1)

Assigns YestValue to the value of the imported indicator on the previous bar when this is the case (since the previous bar would be the last bar of the previous day).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
shcorp886
Posted : Monday, June 10, 2013 3:32:30 PM
Registered User
Joined: 11/4/2009
Posts: 81

hi Bruce,

on realcode, how to get the yesterday low, high, close of current chart symbol. i understand if on daily chart i can use the realcode above to get the yesterday bar value but only 15 minute chart i am geting last bar of yesterday value.

thank you again

 

shcorp886
Posted : Monday, June 10, 2013 3:44:53 PM
Registered User
Joined: 11/4/2009
Posts: 81

i just found one the realcode on your previous post,

Static High(1) As Single
Static Low(1) As Single
Static Close1 As Single
If isFirstBar Then
High(1) = Single.NaN
High(0) = Single.NaN
Low(1) = Single.NaN
Low(0) = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
High(1) = High(0)
High(0) = Price.High
Low(1) = Low(0)
Low(0) = Price.Low
Close1 = Price.Last(1)
Else
High(0) = System.Math.Max(High(0), Price.High)
Low(0) = System.Math.Min(Low(0), Price.Low)
End If
If Single.IsNaN(High(1)) = True Then
Plot = Single.NaN
Else
Plot = (High(1) + Low(1) + Close1) / 3
End If

the high(1) be the yesterday high, low(1) be the yesterday low, and close1 be the yesterday close, right?

 

Bruce_L
Posted : Monday, June 10, 2013 3:57:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

The RealCode given in my Friday, June 07, 2013 2:03:18 PM ET post does not require a Daily Time Frame to work. It works in any Time Frame that is Daily or shorter (including 15-Minute). The YestValue variable represents yesterday's close.

The following RealCode calculates the Open, High, Low and Close so far during the day and for the previous day in Daily and shorter Time Frames.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Yesterday
'|******************************************************************
Static DayOpen(1) As Single
Static DayHigh(1) As Single
Static DayLow(1) As Single
Static DayClose(1) As Single
If isFirstBar Then
	For i As Integer = 0 To 1
		DayOpen(i) = Single.NaN
		DayHigh(i) = Single.NaN
		DayLow(i) = Single.NaN
		DayClose(i) = Single.NaN
	Next
Else If Price.DateValue.Day <> Price.DateValue(1).Day Then
	DayOpen(1) = DayOpen(0)
	DayOpen(0) = Price.Open
	DayHigh(1) = DayHigh(0)
	DayHigh(0) = Price.High
	DayLow(1) = DayLow(0)
	DayLow(0) = Price.Low
	DayClose(1) = Price.Last(1)
	DayClose(0) = Price.Last
Else
	DayHigh(0) = System.Math.Max(DayHigh(0), Price.High)
	DayLow(0) = System.Math.Min(DayLow(0), Price.Low)
	DayClose(0) = Price.Last
End If
If Single.IsNaN(DayOpen(1)) Then
	OpenValue = Single.NaN
	HighValue = Single.NaN
	LowValue = Single.NaN
	Plot = Single.NaN
Else
	OpenValue = DayOpen(1)
	HighValue = DayHigh(1)
	LowValue = DayLow(1)
	Plot = DayClose(1)
End If

DayOpen(0) is the open of the current day, DayHigh(0) is the high of the current day so far, DayLow(0) is the low of the current day so far, DayClose(0) is the current price (which becomes the close after market close, DayOpen(1) is open of the previous day, DayHigh(1) is the high of the previous day, DayLow(1) is the low of the previous day and DayClose(1) is the close of the previous day.

In the RealCode given in your Monday, June 10, 2013 3:44:53 PM ET post, High(0) represents the high of the current day so far, Low(0) represents the low of the current trading day so far, High(1) represents the high of the previous trading day, Low(1) represents the low of the previous trading day and Close1 represents the close of the previous trading day.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.