Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/12/2007 Posts: 10
|
I need to write code for an accumulation scan with the following rules:
1. Scan looks at volume over last ten-day period.
2. Strategy requires that volume be at least 30% above the
21 day average on three up days during last ten days, and no
above average volume on any down days
Can you help me with this?
Thanks,
Gio
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following RealCode Rule:
Static Up As Integer
Static Dn As Integer
Static AvgV21(9) As Single
If isFirstBar Then
Up = 0
Dn = 0
For i As Integer = 0 To 9
AvgV21(i) = 0
Next
End If
If CurrentIndex >= 30 Then
If Volume(10) >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) > Price.Last(11) Then Up -= 1
If Volume(10) > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) < Price.Last(11) Then Dn -= 1
End If
AvgV21(CurrentIndex Mod 10) = AvgV21((CurrentIndex + 9) Mod 10) + Volume / 21
If CurrentIndex >= 21 Then AvgV21(CurrentIndex Mod 10) = _
AvgV21(CurrentIndex Mod 10) - Volume(21) / 21
If CurrentIndex >= 20 Then
If Volume >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last > Price.Last(1) Then Up += 1
If Volume > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last < Price.Last(1) Then Dn += 1
End If
If CurrentIndex >= 29 Then
If Up >= 3 AndAlso Dn = 0 Then Pass
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/12/2007 Posts: 10
|
Thanks Bruce. The scan works very well. Could you please tell me what parameters I need to change to now create a distribution scan with the same rules?
1. Scan looks at volume over last ten-day period.
2. Strategy requires that volume be at least 30% above the
21-day average on three down days during last ten days
3. No above average volume on any up days
Gio
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try the following RealCode Rule:
Static Up As Integer
Static Dn As Integer
Static AvgV21(9) As Single
If isFirstBar Then
Up = 0
Dn = 0
For i As Integer = 0 To 9
AvgV21(i) = 0
Next
End If
If CurrentIndex >= 30 Then
If Volume(10) > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) > Price.Last(11) Then Up -= 1
If Volume(10) >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) < Price.Last(11) Then Dn -= 1
End If
AvgV21(CurrentIndex Mod 10) = AvgV21((CurrentIndex + 9) Mod 10) + Volume / 21
If CurrentIndex >= 21 Then AvgV21(CurrentIndex Mod 10) = _
AvgV21(CurrentIndex Mod 10) - Volume(21) / 21
If CurrentIndex >= 20 Then
If Volume > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last > Price.Last(1) Then Up += 1
If Volume >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last < Price.Last(1) Then Dn += 1
End If
If CurrentIndex >= 29 Then
If Dn >= 3 AndAlso Up = 0 Then Pass
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 9/18/2009 Posts: 60
|
I loaded this in SF and had a bunch of complier errors. Is it possible to update this?
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
You have to use Volume.value now in RealCode instead of just Volume. Try this:
Static Up As Integer
Static Dn As Integer
Static AvgV21(9) As Single
If isFirstBar Then
Up = 0
Dn = 0
For i As Integer = 0 To 9
AvgV21(i) = 0
Next
End If
If CurrentIndex >= 30 Then
If Volume.value(10) > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) > Price.Last(11) Then Up -= 1
If Volume.value(10) >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last(10) < Price.Last(11) Then Dn -= 1
End If
AvgV21(CurrentIndex Mod 10) = AvgV21((CurrentIndex + 9) Mod 10) + Volume.value / 21
If CurrentIndex >= 21 Then AvgV21(CurrentIndex Mod 10) = _
AvgV21(CurrentIndex Mod 10) - Volume.value(21) / 21
If CurrentIndex >= 20 Then
If Volume.value > AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last > Price.Last(1) Then Up += 1
If Volume.value >= 1.3 * AvgV21(CurrentIndex Mod 10) AndAlso _
Price.Last < Price.Last(1) Then Dn += 1
End If
If CurrentIndex >= 29 Then
If Dn >= 3 AndAlso Up = 0 Then Pass
Else
SetIndexInvalid
End If
|
|
Guest-1 |