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

Max high and Min low difference Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
VA_Bear
Posted : Thursday, April 29, 2010 9:21:28 AM
Registered User
Joined: 3/4/2005
Posts: 94
In stockfinder, I would like to be able to find the max high in the say last 100 bars.  I would then like to be able to subtract the min low from that high.  If i looked at the min low for the last 100 bars I could get a min low that was before the max high.

Thanks for the help.

Bruce_L
Posted : Thursday, April 29, 2010 10:54:53 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The following RealCode Indicator includes the Low of the Bar of the MaxHigh when calculating the range since there is no way of knowing if that Low happened before or after the High of the Bar:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Range Since High
'|******************************************************************
'# Period = UserInput.Integer = 100
Static Top As Single
Static TopIndex As Integer
Static Drop As Single
If CurrentIndex > Period Then
    If Price.High >= Top Then
        Top = Price.High
        TopIndex = CurrentIndex
        Drop = Price.Low
    Else If CurrentIndex - TopIndex = Period Then
        Top = Price.MaxHigh(Period)
        For i As Integer = 0 To Period - 1
            Drop = System.Math.Min(Drop, Price.Low(i))
            If Price.High(i) = Top Then
                TopIndex = CurrentIndex - i
                Exit For
            End If
        Next
    Else
        Drop = System.Math.Min(Drop, Price.Low)
    End If
    Plot = Top - Drop
Else If CurrentIndex = Period Then
    Top = Price.MaxHigh(Period)
    Drop = Price.Low
    For i As Integer = 0 To Period - 1
        Drop = System.Math.Min(Drop, Price.Low(i))
        If Price.High(i) = Top Then
            TopIndex = CurrentIndex - i
            Exit For
        End If
    Next
    Plot = Top - Drop
Else
    Plot = Single.NaN
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
VA_Bear
Posted : Thursday, April 29, 2010 11:47:39 AM
Registered User
Joined: 3/4/2005
Posts: 94
Bruce:
That works great.  Thanks for the solution.

Va_Bear
Bruce_L
Posted : Thursday, April 29, 2010 11:54:05 AM


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.