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 |

a PIVOT question Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
hotrod
Posted : Wednesday, December 3, 2008 10:01:01 AM
Registered User
Joined: 10/7/2004
Posts: 67

In a realcode rule I want a rule that "passes" if the most recent PRICE is greater than R2

 

There are several different methods for calculating pivot points, the most common of which is the five-point system. This system uses the previous day's high, low and close, along with two support levels and two resistance levels (totaling five price points) to derive a pivot point. The equations are as follows:

R2 = P + (H - L) = P + (R1 - S1)
R1 = (P x 2) - L
P = (H + L + C) / 3
S1 = (P x 2) - H
S2 = P - (H - L) = P - (R1 - S1) 

Bruce_L
Posted : Wednesday, December 3, 2008 10:24:22 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Do you want the Pivots calculated using the current or previous Bar?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hotrod
Posted : Wednesday, December 3, 2008 10:34:07 AM
Registered User
Joined: 10/7/2004
Posts: 67

previous days bar

hotrod
Posted : Wednesday, December 3, 2008 10:42:19 AM
Registered User
Joined: 10/7/2004
Posts: 67
I am using STOCKGUYS posting in chatrts dated 5/1/2008 and want to base a your code on that indicator
Bruce_L
Posted : Wednesday, December 3, 2008 10:47:06 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following RealCode Rule:

If Price.Last > (5 * Price.High(1) + 2 * Price.Last(1) - 4 * Price.Low(1)) / 3 Then Pass

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hotrod
Posted : Wednesday, December 3, 2008 1:08:44 PM
Registered User
Joined: 10/7/2004
Posts: 67
I am not sure about this formula - after inserting the code in a rule, it does not work.
Bruce_L
Posted : Wednesday, December 3, 2008 1:14:09 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
What do you mean by "not work"? Is it producing an error message?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hotrod
Posted : Wednesday, December 3, 2008 1:54:06 PM
Registered User
Joined: 10/7/2004
Posts: 67

on second look - the code does work.  Your formula is different then the one I submitted.

 

What i was really looking for was a Rule ,  where I could interchange “r4” or  “s2”  greater than or less than the price..last then  pass.

 

 

R4 = R3 + RANGE (same as: PP + RANGE * 3)

                        R3 = R2 + RANGE (same as: PP + RANGE * 2)

                        R2 = PP + RANGE

                        R1 = (2 * PP) - LOW

                        PP = (HIGH + LOW + CLOSE) / 3

                        S1 = (2 * PP) - HIGH

                        S2 = PP - RANGE

                        S3 = S2 - RANGE (same as: PP - RANGE * 2)

                        S4 = S3 - RANGE (same as: PP - RANGE * 3)

 

 

Bruce_L
Posted : Wednesday, December 3, 2008 3:43:32 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You might want to try the following RealCode Rule:

'# PointType = UserInput.String
'# Compare = UserInput.String
Static Pivot As Single
If PointType = "R4" Then
    Pivot = (5 * Price.High(1) - 4 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "R3" Then
    Pivot = (4 * Price.High(1) - 3 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "R2" Then
    Pivot = (3 * Price.High(1) - 2 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "R1" Then
    Pivot = (2 * Price.High(1) - Price.Low(1) + 2 * Price.Last(1)) / 3
Else If PointType = "S1" Then
    Pivot = (Price.High(1) - 2 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "S2" Then
    Pivot = (2 * Price.High(1) - 3 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "S3" Then
    Pivot = (3 * Price.High(1) - 4 * Price.Low(1) + 2 * Price.Last) / 3
Else If PointType = "S4" Then
    Pivot = (4 * Price.High(1) - 5 * Price.Low(1) + 2 * Price.Last) / 3
Else
    Pivot = (Price.High(1) + Price.Low(1) + Price.Last(1)) / 3
End If
If Compare = ">" Then
    If Price.Last > Pivot Then
        Pass
    End If
Else
    If Price.Last < Pivot Then
        Pass
    End If   
End If

You need to put in the type of Pivot Point and a > or < in the appropriate fields in the Main tab of the Edit Rule window. It would be possible to create something more sophisticated that would extract the comparison from a single string and calculate the number of Ranges instead of using an If Then construct to choose choose from pre-defined possibilites (but please keep in mind I am not a programmer).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
hotrod
Posted : Wednesday, December 3, 2008 4:11:05 PM
Registered User
Joined: 10/7/2004
Posts: 67

I hate to contradict you – but u certainly r a programmer. Where is there documentation on realcode for Stockfinder? The code here seems to be nothing like the old Blocks 3.0

In Blocks we could drag indicators into real code to create a new indicator or condition. Can we still do this?

StockGuy
Posted : Wednesday, December 3, 2008 4:19:00 PM

Administration

Joined: 9/30/2004
Posts: 9,187

There's a link to the reference in the StockFinder 4.0 | RealCode forum. 

In 4.0, you cannot drag indiators into the editor but there is an Indicators/Rules button at the top of the editor.  Click that and you can pick which rules/indicators on your chart you want included in the RealCode.  In the end it accomplishes the same thing.

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.