Subscription & data-feed pricing Class schedule

Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.

 Help Coding Combined Indicator Rate this Topic:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
danielbender
 Posted : Friday, April 06, 2018 1:14:32 PM
Platinum Customer

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

Bruce_L
 Posted : Monday, April 09, 2018 2:52:11 PM

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
danielbender
 Posted : Monday, April 09, 2018 7:02:05 PM
Platinum Customer

Joined: 1/14/2006
Posts: 436

yes, both a and b should occur on the same bar.  Thanks.

Bruce_L
 Posted : Tuesday, April 10, 2018 10:44:59 AM

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.

``````'|******************************************************************
'|*** 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
danielbender
 Posted : Tuesday, April 10, 2018 2:31:19 PM
Platinum Customer

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.

Bruce_L
 Posted : Tuesday, April 10, 2018 3:11:07 PM

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
danielbender
 Posted : Wednesday, April 11, 2018 2:20:37 AM
Platinum Customer

Joined: 1/14/2006
Posts: 436

Bruce - thank you

Bruce_L
 Posted : Wednesday, April 11, 2018 9:37:57 AM

Worden Trainer

Joined: 10/7/2004
Posts: 65,138

You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

 Forum Jump Customer Training & Support - Ask a Trainer - TC2000 version 12/18 - Ask a Trainer - TC2000 version 7 - Ask a Trainer - StockFinder 5.0 - PCFs, EasyScan and Custom Indicators General Discussions - Stock and Market Talk - TC2000 version 12 or 18 - TC2000 version 7 - StockFinder 5.0 - RealCode for StockFinder 5.0 Tutorial Videos - TC2000 version 12 tutorial videos - TC2000 version 7 tutorial videos 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.