Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

New Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
ucsense
Posted : Monday, February 22, 2010 2:02:07 PM
Registered User
Joined: 12/12/2006
Posts: 77
Good Afternoon!

I am seeking help creating a PCF or Scan that searches for stocks with a 20 EMA crossing a 50 EMA. They would be crossing with an increase of at least 25% over yesterday's volume. The movement may be either up or down - preferably in separate searches.

Thank you for your assistance! 

ucsense1
Bruce_L
Posted : Monday, February 22, 2010 2:07:27 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try one of the following Personal Criteria Formulas:

EMA20 xUp EMA50 with 25% increase in Volume:

XAVGC20 > XAVGC50 AND XAVGC20.1 <= XAVGC50.1 AND V > 1.25 * V1

EMA20 xDn EMA50 with 25% increase in Volume:

XAVGC20 < XAVGC50 AND XAVGC20.1 >= XAVGC50.1 AND V > 1.25 * V1

EMA20 crossing EMA50 (either direction) with 25% increase in Volume:

SGN(XAVGC20 - XAVGC50) <> SGN(XAVGC20.1 - XAVGC50.1) AND V > 1.25 * V1

You may wish to review the following:

Moving Average PCF Templates
Things to check if your moving averages don't "seem right" or "seem to match"
How to create a Personal Criteria Forumula (PCF)
PCF Formula Descriptions

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ucsense
Posted : Monday, February 22, 2010 10:46:49 PM
Registered User
Joined: 12/12/2006
Posts: 77
Thanks, Bruce! Just what I needed!
Bruce_L
Posted : Tuesday, February 23, 2010 8:53:36 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ucsense
Posted : Monday, February 21, 2011 4:05:21 PM
Registered User
Joined: 12/12/2006
Posts: 77

Recently, I came upon a Condition you created which required a bit of time to create. This is something I have been working on for a period of time but nowhere near as close to the formula you created. This particular Condition concentrated on the downside.

I am more interested in the upside. I am attaching the formula for the downside condition and am asking you to assist me to the upside. I know there are a number of changes necessary but, as I know next to nothing of Real Code, I fear that I would screw it up on my own.

Here is the Condition:

'# BBTop = chart.BollingerBands.0
'# BBBottom = chart.BollingerBands.1
'# Percent = UserInput.Single = 1
'# DiffTop = UserInput.Single = 0.3
'# DiffBot = UserInput.Single = 0.3
'# Cumulative
Static MaDownCount As Integer
Static WithinCount As Integer
Static SixMonthBars As Integer
If isFirstBar Then
    If isYearly Then
        SixMonthBars = 1
    Else If isQuarterly Then
        SixMonthBars = 2
    Else If isMonthly Then
        SixMonthBars = 6
    Else If isWeekly Then
        SixMonthBars = 26
    Else If BarInterval.TotalDays >= 1 Then
        SixMonthBars = 126 / BarInterval.TotalDays
    Else
        SixMonthBars = 126 * System.Math.Ceiling(390 / BarInterval.TotalMinutes)
    End If
End If
If Price.Last(3) <= BBTop.Value(3) AndAlso _
    Price.Last(3) >= BBBottom.Value(3) AndAlso _
    Price.Open(3) <= BBTop.Value(3) AndAlso _
    Price.Open(3) >= BBBottom.Value(3) Then
    WithinCount += 1
Else
    WithinCount = 0
End If
If CurrentIndex >= 20 Then
    If Price.Last < Price.Last(10) AndAlso _
        Price.Last < Price.Last(20) Then
        MaDownCount += 1
    Else
        MaDownCount = 0
    End If
    If CurrentIndex >= 22 Then
        If 100 * (1 - BBBottom.Value(1) / BBBottom.AVG(5, 3)) > Percent AndAlso _
            MaDownCount >= 3 AndAlso _
            WithinCount >= 5 AndAlso _
            Price.Last > Price.Open AndAlso _
            Price.Last(1) < Price.Open(1) AndAlso _
            Price.Last(1) < BBBottom.Value(1) AndAlso _
            Price.Last(2) < Price.Open(2) Then
            Dim Avg As Single = (BBTop.AVG(5, 3) + BBBottom.AVG(5, 3)) / 2
            Dim LowPerc(1) As Single
            LowPerc(0) = Single.MaxValue
            LowPerc(1) = Single.MaxValue
            Dim AvgPerc(1) As Single
            AvgPerc(0) = 0
            AvgPerc(1) = 0
            For j As Integer = 0 To 4
                Dim Perc As Single = 100 * (1 - Avg / BBTop.Value(3 + j))
                LowPerc(0) = System.Math.Min(LowPerc(0), Perc)
                AvgPerc(0) += Perc
                Perc = 100 * (1 - BBBottom.Value(3 + j) / AVG)
                LowPerc(1) = System.Math.Min(LowPerc(1), Perc)
                AvgPerc(1) += Perc
            Next
            AvgPerc(0) = AvgPerc(0) / 5
            AvgPerc(1) = AvgPerc(1) / 5
            Dim HighPeriod As Integer = System.Math.Min(CurrentIndex, SixMonthBars)
            If AvgPerc(0) - LowPerc(0) < DiffTop AndAlso _
                AvgPerc(1) - LowPerc(1) < DiffBot AndAlso _
                Price.MaxClose(5, 3) >= .94 * Price.MaxHigh(HighPeriod) Then
                Pass
            End If
        End If
    Else
        SetIndexInvalid
    End If
Else
    MaDownCount = 0
    SetIndexInvalid
End If

If you need any further information, I will supply it ASAP. 

Thank you!
ucsense1

Bruce_L
Posted : Tuesday, February 22, 2011 2:47:28 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I seriously would have little idea in how to convert the supposedly downside RealCode Condition given into an upside version (I did not even know it concentrated on the downside) as much of the RealCode is just rote implementation of SageRx's algorithms into RealCode.

Some things would seem obvious. Everything having to do with WithinCount and SixMonthBars would remain the same same.

Static MaDownCount As Integer

And:


    If Price.Last < Price.Last(10) AndAlso _
        Price.Last < Price.Last(20) Then
        MaDownCount += 1
    Else
        MaDownCount = 0
    End If

And:


            MaDownCount >= 3 AndAlso _

Would probably become:

Static MaUpCount As Integer

And:


    If Price.Last > Price.Last(10) AndAlso _
        Price.Last > Price.Last(20) Then
        MaUpCount += 1
    Else
        MaUpCount = 0
    End If

And:


            MaUpCount >= 3 AndAlso _

While:

Price.Last > Price.Open AndAlso _
            Price.Last(1) < Price.Open(1) AndAlso _
            Price.Last(1) < BBBottom.Value(1) AndAlso _
            Price.Last(2) < Price.Open(2) Then

Would probalby become:

Price.Last < Price.Open AndAlso _
            Price.Last(1) > Price.Open(1) AndAlso _
            Price.Last(1) > BBTop.Value(1) AndAlso _
            Price.Last(2) > Price.Open(2) Then


A also suspect:

            Dim HighPeriod As Integer = System.Math.Min(CurrentIndex, SixMonthBars)


And:


                Price.MaxClose(5, 3) >= .94 * Price.MaxHigh(HighPeriod) Then


Would become

            Dim LowPeriod As Integer = System.Math.Min(CurrentIndex, SixMonthBars)

And:


                Price.MinClose(5, 3) <= 1.06 * Price.MinLow(LowPeriod) Then


But I really do not know how or even if anything relating to calculating the variables used in the following two lines would change (and that constitutes a significant portion of the RealCode):

            If AvgPerc(0) - LowPerc(0) < DiffTop AndAlso _
                AvgPerc(1) - LowPerc(1) < DiffBot AndAlso _


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