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 |

syntax for a swing high Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
pipeacosta
Posted : Monday, July 20, 2009 12:38:14 PM
Registered User
Joined: 4/12/2008
Posts: 41
I want to create a rule in RC that points out peaks or swing highs, the rule does this:At least 5 lower highs to the left, AND TO THE RIGHT of the bar. Whats the syntax? Thanks
Bruce_L
Posted : Monday, July 20, 2009 12:53:09 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you want a Rule that would identify this at the correct Point on the Chart, you could try something like the following if the Highs only need to be lower than the center High:

If Price.MaxHigh(5, -5) < Price.High AndAlso _
    Price.MaxHigh(5, 1) < Price.High Then Pass

If you want a Rule that would identify this at the correct Point on the Chart, you could try something like the following if the Highs need to be lower than the adjacent High closest to the center High:

If Price.High(-5) < Price.High(-4) AndAlso _
    Price.High(-4) < Price.High(-3) AndAlso _
    Price.High(-3) < Price.High(-2) AndAlso _
    Price.High(-2) < Price.High(-1) AndAlso _
    Price.High(-1) < Price.High AndAlso _
    Price.High(1) < Price.High AndAlso _
    Price.High(2) < Price.High(1) AndAlso _
    Price.High(3) < Price.High(2) AndAlso _
    Price.High(4) < Price.High(3) AndAlso _
    Price.High(5) < Price.High(4) Then Pass

These sorts of Rules use future values however and should never be used in Backtesting. If you are going to use the Rules in BackScanner you should create a Rule for when the swing high was detected, not for Bar which actually was the swing high. This involves adding 5 to all of the Offsets in the RealCode. If you want a Rule that would identify a pivot high where it was detected, you could try something like the following if the Highs only need to be lower than the center High:

If Price.MaxHigh(5) < Price.High(5) AndAlso _
    Price.MaxHigh(5, 6) < Price.High(5) Then Pass
    
If you want a Rule that would identify a pivot high where it was detected, you could try something like the following if the Highs need to be lower than the adjacent High closest to the center High:

If Price.High < Price.High(1) AndAlso _
    Price.High(1) < Price.High(2) AndAlso _
    Price.High(2) < Price.High(3) AndAlso _
    Price.High(3) < Price.High(4) AndAlso _
    Price.High(4) < Price.High AndAlso _
    Price.High(6 ) < Price.High AndAlso _
    Price.High(7) < Price.High(6 ) AndAlso _
    Price.High(8) < Price.High(7) AndAlso _
    Price.High(9) < Price.High(8) AndAlso _
    Price.High(10) < Price.High(9) Then Pass

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