Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Minimize Sorting Time for an Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
danielbender
Posted : Wednesday, May 23, 2018 12:30:43 PM
Registered User
Joined: 1/14/2006
Posts: 436

Bruce

How do I optimize the following indicator to only look at the last 500 bars, to minimize the time needed to sort?

Thank  you... Dan

++++++++++

'|******************************************************************
'|*** 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
'# Component = UserInput.Integer = 1
 
 
Static Count As Single
Static Marker As Single
Static Lo As Single
Static Entry As Single
Static Pop As Single
 
If isfirstBar Then
Count = Single.NaN
Marker = 0
Pop = 0
Else If (Marker = 0 AndAlso _
(SMI.value > SMI.Value(1) AndAlso SMI.Value(1) < 0 OrElse _
Price.Close - Price.Open > 3 * (Price.Close(1) - Price.Open(1))))Then
Marker = 1
Count = 1
Lo = Price.Low
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
If Count = 3 Then 
Pop = Price.Close - Lo
Entry = Price.Close
End If
Else
Count = 0
Marker = 0
Pop = 0
End If
'If Count >= 2 Then
' Plot = Count
'Else
' Plot = 0
'End If
 
If Component = 1 Then
Plot = Count
Else If Component = 2 Then
If Count > 3
Plot = Price.Close - Entry
Else 
Plot = 0
End If
End If
Bruce_L
Posted : Wednesday, May 23, 2018 12:56:21 PM


Worden Trainer

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

You won't be able to do anything to the code as the SMI indicator should have the '#Cumulative property since it is based on exponential moving averages. This means it will try to use all of the available data.

There are two ways to limit the amount of data used.

You can go to Settings | Data Manager and adjust the number of bars for the entire program.

You can edit the Block Diagram of an indicator to add a Length Limit Block to the Length Limit input of any Prices or Volume bars in a Block Diagram.

Unfortunately while you may be able to edit the Block Diagram for the RealCode Indicator (or possibly not), it technically isn't editable and such changes will not survive a program restart (you might have better luck editing the Block Diagram for the SMI indicator itself).

Building Your First 3 Block Diagrams (9:54)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
danielbender
Posted : Wednesday, May 23, 2018 5:23:34 PM
Registered User
Joined: 1/14/2006
Posts: 436

Bruce,  If I did not have SMI indicator in the indicator, could I limit the amount of data backtested? 

Bruce_L
Posted : Thursday, May 24, 2018 9:36:28 AM


Worden Trainer

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

Without a '#Cumulative indicator (or tag in the RealCode), a WatchList Column / sort will automatically try to minimize the amount of data used (usually drops to about 50 bars).

You can override the number of bars to use by adding something similar to the following between the Inherits and Public Overrides lines in the Class tab of the RealCode Editor (what to use instead of 20 is up to you):

    Sub New
        NumOfBars = 20
    End Sub

The RealCode Programmers Reference covers this and more advanced techniques such as creating your own manual loops instead of using the autoloop in more detail.



-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.