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

new realcode.. Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
shcorp886
Posted : Wednesday, March 6, 2013 11:54:12 AM
Registered User
Joined: 11/4/2009
Posts: 81

Hi Bruce,

I would like to ask for your help to write a realcode indicator.

actually, 2 realcodes (both about the same);

indicator 1: plot the highest point of the price above the 50 moving average and remain the same after current close across below the 50moving average until the current close above the moving average;

indicator 2: plot the lowest point of the price below the 50 moving average and remain the same after current close across above the 50 moving average until the current close below the moving average.

can you also show me how to put both indicators in one  realcode?

thank you

 

Bruce_L
Posted : Wednesday, March 6, 2013 12:11:55 PM


Worden Trainer

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

You can only output either a single value at each bar or the open, high, low and close at each bar using a RealCode Indicator. It is not possible to plot two values using a single RealCode Indicator.

A RealCode Indicator for the Highest High with the Close above the 50-Period Simple Moving Average of price could be written as:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Highest High with Close above Moving Average
'|******************************************************************
'# Period = UserInput.Integer = 50
Static Highest As Single
If isFirstBar Then
	Highest = Single.NaN
Else If Price.Last > Price.AVGC(Period) Then
	If Price.Last(1) <= Price.AVGC(Period, 1) Then
		Highest = Price.High
	Else
		Highest = System.Math.Max(Highest, Price.High)
	End If
End If
Plot = Highest

A RealCode Indicator for the Highest High with the Close above the 50-Period Simple Moving Average of price could be written as:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Lowest Low with Close below Moving Average
'|******************************************************************
'# Period = UserInput.Integer = 50
Static Lowest As Single
If isFirstBar Then
	Lowest = Single.NaN
Else If Price.Last < Price.AVGC(Period) Then
	If Price.Last(1) >= Price.AVGC(Period, 1) Then
		Lowest = Price.Low
	Else
		Lowest = System.Math.Min(Lowest, Price.Low)
	End If
End If
Plot = Lowest


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
shcorp886
Posted : Friday, March 8, 2013 12:39:29 PM
Registered User
Joined: 11/4/2009
Posts: 81

Hi Bruce,

thank you for the real code, it works great.

I like to ask if I like to plot the lowest point of last 10 period when the crossing occur.

do i change  lowest=minlow(10) only or change both lowest=minlow(10) and lowest=system.math.min(lowest,minlow(10))

 

Bruce_L
Posted : Friday, March 8, 2013 12:44:21 PM


Worden Trainer

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

If I'm understanding your request correctly, you should only need to change Lowest = Price.Low to Lowest = Price.MinLow(10). The Lowest = System.Math.Min(Lowest, Price.Low) section is just there to lower the low after the cross, not at the point of the cross.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
shcorp886
Posted : Friday, March 8, 2013 1:16:11 PM
Registered User
Joined: 11/4/2009
Posts: 81

okay, thank you

that works for me.

Bruce_L
Posted : Friday, March 8, 2013 1:21:13 PM


Worden Trainer

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

You're welcome.



-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.