Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Problem Compiling Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
danielbender
Posted : Wednesday, May 09, 2018 2:28:03 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

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
Bruce_L
Posted : Wednesday, May 09, 2018 2:51:10 PM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704

Please try using SMI.Value and SMI.Value(1) instead of SMI and SMI(1).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
danielbender
Posted : Wednesday, May 09, 2018 3:15:07 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

Bruce - That worked.  Now having problem compiling this modification.   Code beginning with 

"Else If Marker = 1 AndAlso" is not compiling.  Thanks.

danielbender
Posted : Wednesday, May 09, 2018 3:15:45 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

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
Bruce_L
Posted : Wednesday, May 09, 2018 3:30:46 PM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704

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
danielbender
Posted : Wednesday, May 09, 2018 4:27:43 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

Sorry - I want

 

Else if Marker = 1 ANDALSO ( (Orelse ....  Orelse....Orelse) .... Than

 

Is that possible?

danielbender
Posted : Wednesday, May 09, 2018 4:33:19 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425
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
Bruce_L
Posted : Wednesday, May 09, 2018 4:45:45 PM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704
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
danielbender
Posted : Wednesday, May 09, 2018 5:53:40 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425
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
 
danielbender
Posted : Wednesday, May 09, 2018 6:05:12 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

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

Bruce_L
Posted : Thursday, May 10, 2018 11:19:14 AM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704

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
danielbender
Posted : Thursday, May 10, 2018 12:13:02 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

Bruce

Thanks.  

 
How do I set the 3 parameters for SMI within the indictor?
 
Thanks
Bruce_L
Posted : Thursday, May 10, 2018 12:17:01 PM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704

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
danielbender
Posted : Thursday, May 10, 2018 1:54:57 PM
Platinum Customer Platinum Customer

Joined: 1/14/2006
Posts: 425

thx

Bruce_L
Posted : Thursday, May 10, 2018 1:58:58 PM


Worden Trainer

Joined: 10/7/2004
Posts: 62,704

You're welcome.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.