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

Comparative current daily range Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
brakkar
Posted : Wednesday, October 19, 2011 5:20:44 AM
Registered User
Joined: 1/25/2005
Posts: 39
Hi Bruce,

can you tell me if such indicator already exists for stockfinder please ? It's a bit similar to what I asked about volume comparison, but with current day range:

We calculate current intraday day range (NOT atr) up to that time of day: H-L.So for example, le'ts say at 11:15 Goog has a H-L range of $1 we call this number A.

Then we calculate full daily range (H-L) average for goog over latest XX days. We call it B.

We then calculate how much A is percent of B.
So for example a reading of 0.25 on intraday chart at 11:15 am, means that from 9:30 to 11:15, goog range is 25% of its average full day range over latest xx days.

Cordially,Brak
Bruce_L
Posted : Wednesday, October 19, 2011 9:29:03 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I am not aware of any similar indicator being created previously. You should be able to replace everything below the Inherits line in the Class tab of a RealCode Indicator with the following to create the RealCode Indicator:

    '# Period = UserInput.Integer = 30
    Sub New
        AutoLoop = False
    End Sub
    Public Overrides Function Plot() As System.Single
        If TimeFrame.TotalDays < 1 AndAlso Period >= 2 Then
            Dim Start(Period-1) As Integer
            Dim DayCount As Integer = -1
            Dim BarCount As Single = 0
            Dim DayHigh As Single = Single.MinValue
            Dim DayLow As Single = Single.MaxValue
            Dim SMA As New System.Collections.Generic.List(Of Single)
            For i As Integer = 1 To Price.Bar.Count - 1
                If Price.Bar.DateValue(i).DayOfYear <> Price.Bar.DateValue(i - 1).DayOfYear Then
                    DayCount += 1
                    BarCount = 0
                    If DayCount >= Period Then
                        Dim j As Integer = 0
                        DayHigh = Single.MinValue
                        DayLow = Single.MaxValue
                        For k As Integer = Start(DayCount Mod Period) To Start((DayCount + 1) Mod Period) - 1
                            DayHigh = System.Math.Max(DayHigh, Price.Bar.HighValue(k ))
                            DayLow = System.Math.Min(DayLow, Price.Bar.HighValue(k ))
                            SMA(j) -= DayHigh - DayLow
                            j += 1
                        Next
                    End If
                    DayHigh = Single.MinValue
                    DayLow = Single.MaxValue
                    Start(DayCount Mod Period) = i
                End If
                DayHigh = System.Math.Max(DayHigh, Price.Bar.HighValue(i))
                DayLow = System.Math.Min(DayLow, Price.Bar.HighValue(i))
                If DayCount >= 0 Then
                    If BarCount >= SMA.Count Then
                        SMA.Add(DayHigh - DayLow)
                    Else
                        SMA(BarCount) += DayHigh - DayLow
                    End If
                End If
                If DayCount >= Period - 1 Then
                    If SMA(BarCount) > 0 Then
                        AddToOutput(Price.Bar.DateValue(i), (DayHigh - DayLow) / _
                            (SMA(BarCount) / Period))
                    End If
                End If
                BarCount += 1
            Next
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
brakkar
Posted : Wednesday, October 19, 2011 9:41:41 AM
Registered User
Joined: 1/25/2005
Posts: 39
Thanks a lot Bruce, but i think it doesn't behave properly:

Normaly value must never go down: H-L of today can only increase, yet it seems indicator is following current bar, instead of comparing H-L of today, to H-L average of XX days ago...
Bruce_L
Posted : Wednesday, October 19, 2011 9:45:57 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Unless you are misdescribing the indicator or I am misunderstanding your explanation of the indicator, your analysis would appear to be incorrect.

The H - L of the Current Day can only go up.

The Average H - L can only go up.

The H - L and Average H - L can go up at different rates.

If the H - L of the Current Day goes up at a faster rate than the Average H - L, then the Indicator will increase.

If the H - L of the Current Day goes up at a slower rate than the Average H - L, then the Indicator will decrease.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
brakkar
Posted : Wednesday, October 19, 2011 10:04:03 AM
Registered User
Joined: 1/25/2005
Posts: 39

Bruce,
there certainly a misunderstanding, probably my fault:

If at 11:15 stocks made a high, then pulled back, and never made a new high (or low) for the rest of the day, value of indicator must stay the same all day.

if H-L at 11:15 is 25% of average H-L range for last xx days, it should not change unless stocks makes a new high/low.

When I'm talking about previous days range, I mean average of H-L calculated on H-L values of entire days, not at same time of current day.

Am I more clear ?

Tks,
Brak

Bruce_L
Posted : Wednesday, October 19, 2011 10:14:24 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You should be able to replace everything below the Inherits line in the Class tab of a RealCode Indicator with the following to create the RealCode Indicator:

    '# Period = UserInput.Integer = 30
    Sub New
        AutoLoop = False
    End Sub
    Public Overrides Function Plot() As System.Single
        If TimeFrame.TotalDays < 1 AndAlso Period >= 2 Then
            Dim Start(Period-1) As Integer
            Dim DayCount As Integer = -1
            Dim DayHigh As Single = Single.MinValue
            Dim DayLow As Single = Single.MaxValue
            Dim SMA As Single = 0
            For i As Integer = 1 To Price.Bar.Count - 1
                If Price.Bar.DateValue(i).DayOfYear <> Price.Bar.DateValue(i - 1).DayOfYear Then
                    DayCount += 1
                    If DayCount > 0 Then
                        SMA += DayHigh - DayLow
                    End If
                    If DayCount >= Period Then
                        Dim j As Integer = 0
                        DayHigh = Single.MinValue
                        DayLow = Single.MaxValue
                        For k As Integer = Start(DayCount Mod Period) To Start((DayCount + 1) Mod Period) - 1
                            DayHigh = System.Math.Max(DayHigh, Price.Bar.HighValue(k ))
                            DayLow = System.Math.Min(DayLow, Price.Bar.HighValue(k ))
                            j += 1
                        Next
                        SMA -= DayHigh - DayLow
                    End If
                    DayHigh = Single.MinValue
                    DayLow = Single.MaxValue
                    Start(DayCount Mod Period) = i
                End If
                DayHigh = System.Math.Max(DayHigh, Price.Bar.HighValue(i))
                DayLow = System.Math.Min(DayLow, Price.Bar.HighValue(i))
                If DayCount >= Period - 1 Then
                    If SMA > 0 Then
                        AddToOutput(Price.Bar.DateValue(i), (DayHigh - DayLow) / (SMA / Period))
                    End If
                End If
            Next
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
brakkar
Posted : Wednesday, October 19, 2011 10:55:25 AM
Registered User
Joined: 1/25/2005
Posts: 39

Thanks Bruce, seems to be the right calculation.
I really appreciate your help.

Brak

brakkar
Posted : Wednesday, October 26, 2011 6:19:18 PM
Registered User
Joined: 1/25/2005
Posts: 39

Bruce,
i'm trying to do the same in Tc2000 12, would you mind giving a hint:

1) H-L
2) Exponetial Average of H-L over latest 30 bars

then we calculate how much % is H-L of (Exponetial Average of H-L over latest 30 bars)
So for example, if H-L of current bar is 0,7 and the average is 1, indicator would show 30.
So indicator can never be less than 0, since H-L is always >= 0.

Tks,
Benj

Bruce_L
Posted : Thursday, October 27, 2011 7:30:57 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following Indicator Formula using a Daily Time Frame (you will need to use commas instead of periods for the decimals, but I'm posting what works on my system):

100 * (H - L) / (XAVGH30.1 - XAVGL30.1 + .00001)

I cannot think of a way to create a formula for this in TC2000 which would work on anything other than a Daily Time Frame.

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!

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