Registered User Joined: 1/14/2006 Posts: 436
|
Bruce
I would like real code to generate the following counts for daily and 5-minute timeframes
1. Postive count indicating number of bars since:
a) RSI reversed from negative to positive slope AND
b) StochasticMomentumIndex crossed UP through trigger
Please make this count number positive. ie, 1 = 1 bar since last occurrence, 2 = 2 bars since, etc.,
2. Negative count indicating number of bars since (mirror image of above):
a) RSI reversed from positive to negative slope AND
b) StochasticMomentumIndex crossed DOWN through trigger
Please make this count number negative. ie, -1 = 1 bar since last occurrence, -2 = 2 bars since, etc.,
If possible, I would like the ability to adjust the parameters of the indicators and the timeframes.
Thank you.... Dan Bender
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Do a and b have to happen on the same bar?
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 1/14/2006 Posts: 436
|
yes, both a and b should occur on the same bar. Thanks.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You will need to create the '# WR and '# SMI lines yourself by dragging and dropping the indicators from the chart into the RealCode Editor. Initially this will mean changing the indicators on the chart will change the settings. If you save the indicator, you should be able to adjust the settings by just editing the indicator.
RealCode for Real People: Indicators (6:05)
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Since Reversal
'|******************************************************************
'# WR = chart.WildersRSI
'# SMI = chart.StochasticMomentumIndex
'# Trigger = UserInput.Integer = 10
Static Count As Single
Static Sign As Single
If isFirstBar Then
Count = Single.NaN
Sign = 0
Else If WR.Value > WR.Value(1) AndAlso _
WR.Value(1) <= WR.Value(2) AndAlso _
SMI.Value > SMI.XAVG(Trigger) AndAlso _
SMI.Value(1) <= SMI.XAVG(Trigger, 1) Then
Count = 0
Sign = 1
Else If WR.Value < WR.Value(1) AndAlso _
WR.Value(1) >= WR.Value(2) AndAlso _
SMI.Value < SMI.XAVG(Trigger) AndAlso _
SMI.Value(1) >= SMI.XAVG(Trigger, 1) Then
Count = 0
Sign = -1
Else
Count += Sign
End If
Plot = Count
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce - Thank you - An additional request
Could you modify the code to so that a and b occur within one bar of each other, but not necessarily on the same bar? I am getting too few simultaneous triggers when both occur on the same bar. Too restrictive. Thank you.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Maybe the following?
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Since Reversal
'|******************************************************************
'# WR = chart.WildersRSI
'# SMI = chart.StochasticMomentumIndex
'# Trigger = UserInput.Integer = 10
Static Count As Single
Static Sign As Single
If isFirstBar Then
Count = Single.NaN
Sign = 0
Else If WR.Value > WR.Value(1) AndAlso _
SMI.Value > SMI.XAVG(Trigger) AndAlso _
((WR.Value(1) <= WR.Value(2) AndAlso _
SMI.Value(1) <= SMI.XAVG(Trigger, 1)) OrElse _
(WR.Value(1) <= WR.Value(2) AndAlso _
SMI.Value(2) < SMI.XAVG(Trigger, 2)) OrElse _
(WR.Value(2) < WR.Value(3) AndAlso _
SMI.Value(1) <= SMI.XAVG(Trigger, 1))) Then
Count = 0
Sign = 1
Else If WR.Value < WR.Value(1) AndAlso _
SMI.Value < SMI.XAVG(Trigger) AndAlso _
((WR.Value(1) >= WR.Value(2) AndAlso _
SMI.Value(1) >= SMI.XAVG(Trigger, 1)) OrElse _
(WR.Value(1) >= WR.Value(2) AndAlso _
SMI.Value(2) > SMI.XAVG(Trigger, 2)) OrElse _
(WR.Value(2) > WR.Value(3) AndAlso _
SMI.Value(1) >= SMI.XAVG(Trigger, 1))) Then
Count = 0
Sign = -1
Else
Count += Sign
End If
Plot = Count
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce - thank you
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|