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

Translate from Metastock Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
CGTrader
Posted : Monday, June 22, 2009 3:52:43 PM
Registered User
Joined: 9/26/2005
Posts: 49
I am trying to move something from MetaStock to StockFinder.

MetaStock has'

 

The formula "lowestsince( 2, cross(c,mov(c,10,s), close )" returns lowest value of the close since the second most recent occurrence of the close crossing above its 10-day moving average. 

I am using something other than close but if I could do it for close I might be able to do it for any other indicator.

What I want is the lowest value of the function since the last time it crossed the zero line.

I can use a rule to see when Close moves above its 10 day MA.  If I move the Rule to a column I can get #Bars since True. Can I get at this #bars since True in Real Code?

If I could I could use price.MinClose(#bars since true) or something like that.

For something other than close. Can I use something like the System.Math.min function.

Bruce_L
Posted : Monday, June 22, 2009 4:24:59 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You can definitely keep track of the number of Bars since a particular Rule returned True. For example, if you Drag and Drop a Rule into the RealCode Editor, it should create something similar to the first line of the following RealCode Indicator:

'# MR = condition.MyRule
Static Count As Single
If isFirstBar Then Count = Single.NaN
Count += 1
If MR.Value = True Then Count = 0
Plot = Count

You could then use the Count with Price.MinValue(Count) to get the low since the Rule returned True. That said, it's probably more efficient to track the Minimum directly. For example, if you Drag and Drop an Indicator into the RealCode Editor it should create something similar to the first line of the following RealCode Indicator: to display the lowest value of that Indicator since the last time it crossed the zero line (in either direction):

'# Indi = indicator.Indicator
Static Minimum As Single
If isFirstBar Then Minimum = Single.NaN
Minimum = System.Math.Min(Minimum, Indi.Value)
If System.Math.Sign(Indi.Value) <> System.Math.Sign(Indi.Value(1)) Then
    Minimum = Indi.Value
End If
Plot = Minimum

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