Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce
I cannot get this indicator to compile with SMI (Stochastic Momentum Index). See bolded code. What am I doing wrong?
Thanks.
+++++++
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.1 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:UpBar Count
'|*** Example: plot = price.close - price.close(1)
'|******************************************************************
'# SMI = indicator.unlinked.StochasticMomentumIndex
Static Count As Single
If isfirstBar Then
Count = Single.NaN
Else If Price.Open > Price.High(1) OrElse _
Price.Open < Price.Low(1) Then
Count = 0
Else If SMI < 50 AndAlso SMI(1) > 50 Then
Count = 1
Else If (Price.High > Price.High(1) AndAlso Price.Low > Price.Low(1)) OrElse _
(Price.Open > Price.Open(1) AndAlso Price.Close > Price.Close(1)) OrElse _
Price.Close >= 0.999 * Price.XAVGC(8)Then
'Else If Price.Open >= 0.9 * Price.Close(1) AndAlso _
' Price.Close > Price.Open AndAlso (Price.High - Price.Low) > 0.9 * (Price.High(1) - Price.Low(1)) _
' AndAlso Count = 0 Then
Count += 1
'Else If Price.Open >= 0.9 * Price.Close(1) AndAlso _
'Price.Close > Price.Open AndAlso Count > 0 Then
Else
Count = 0
End If
Plot = Count
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try using SMI.Value and SMI.Value(1) instead of SMI and SMI(1).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce - That worked. Now having problem compiling this modification. Code beginning with
"Else If Marker = 1 AndAlso" is not compiling. Thanks.
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
Sorry - here is all the code
Static Count As Single
Static Marker As Single
If isfirstBar Then
Count = Single.NaN
Marker = 0
Else If Price.Open > Price.High(1) OrElse _
Price.Open < Price.Low(1) Then
Count = 0
Else If SMI.value < -50 AndAlso SMI.Value(1) > -50 Then
Marker = 1 AndAlso Count = 1
Else If Marker = 1 AndAlso _
(OrElse(Price.High > Price.High(1) AndAlso Price.Low > Price.Low(1) OrElse _
(Price.Open > Price.Open(1) AndAlso Price.Close > Price.Close(1) OrElse _
Price.Close >= 1.0 * Price.XAVGC(8)) Then
'Else If Price.Open >= 0.9 * Price.Close(1) AndAlso _
' Price.Close > Price.Open AndAlso (Price.High - Price.Low) > 0.9 * (Price.High(1) - Price.Low(1)) _
' AndAlso Count = 0 Then
Count += 1
'Else If Price.Open >= 0.9 * Price.Close(1) AndAlso _
'Price.Close > Price.Open AndAlso Count > 0 Then
Else
Count = 0
Marker = 0
End If
Plot = Count
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You have AndAlso _ and (OrElse right in a row. I don't know which you want. It also looks like you need to add a few closing parentheses. Not sure where they go for sure (but you could always put them between price.XAVGC(8) and Then).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
Sorry - I want
Else if Marker = 1 ANDALSO ( (Orelse .... Orelse....Orelse) .... Than
Is that possible?
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
This is what I am trying to do.
Else If (Marker = 1 AndAlso (_
Price.High > Price.High(1) AndAlso Price.Low > Price.Low(1) OrElse _
Price.Open > Price.Open(1) AndAlso Price.Close > Price.Close(1) OrElse _
Price.Close >= 1.0 * Price.XAVGC(8)
Then
Count += 1
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Else If (Marker = 1 AndAlso _
(Price.High > Price.High(1) AndAlso Price.Low > Price.Low(1) OrElse _
Price.Open > Price.Open(1) AndAlso Price.Close > Price.Close(1) OrElse _
Price.Close >= 1.0 * Price.XAVGC(8))) Then
Count += 1
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce
How do I set the 3 parameters for SMI? And how do I reference the Trigger value for SMI?
Thanks
|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.1 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:UpBar Count
'|*** Example: plot = price.close - price.close(1)
'|******************************************************************
'# SMI = indicator.unlinked.StochasticMomentumIndex
Static Count As Single
Static Marker As Single
If isfirstBar Then
Count = Single.NaN
Marker = 0
Count = 1
Else If SMI.value > SMI.Value(1) AndAlso SMI.Value(1) < -50 Then
Marker = 1 AndAlso Count = 1
Else
Count = 0
Marker = 0
End If
Plot = Count
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
When I run the indicator above, it gives never gives me count = 1. Can you tell me why? I know the SMI.Value changes from below -50 to above -50 for QQQ on April 26. Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You need to get rid of the AndAlso between Marker = 1 and Count = 1. Just put them on their own lines.
You should be able to just click on the name of the indicator on the chart and select Edit. The Period, 1st Smooth, and 2nd Smooth should be listed as options.
The trigger is just an exponential moving average of the SMI. So something like:
SMI.XAVG(10)
Would give you the value of a 10 period trigger line.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
Bruce
Thanks.
How do I set the 3 parameters for SMI within the indictor?
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You don't set them within the RealCode. You edit the indicator (not the RealCode) and it will allow you to adjust the settigs.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/14/2006 Posts: 436
|
thx
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |