Access Common Indicators within Indicator Library
Author: Ben_Zurich
Creation Date: 5/7/2012 3:53 AM
profile picture

Ben_Zurich

#1
I have established an indicator library as described in
QUOTE:
Creating an Indicator Library in Wealth-Lab Pro
which works well. However I did not succeed accessing a common indicator like SMA within the constructor of my custom indicator. Adding the "using WealthLab.Indicators" clause did not help. Could anyone make an example of a constructor of a custom indicator that just duplicates (i.e. calls) an already existing indicator?


Second Question: Assume that I have a custom indicator called SMA_uni, and its constructor looks like this:

CODE:
Please log in to see this code.


This construction works well. Now i want to make another custom indicator called TriMA_uni that uses SMA_uni:

CODE:
Please log in to see this code.


You see, one difference to the above example is the fact that this indicator does not calculate each bar individually but accesses an already existing indicator. However, this construction is not allowed. This assignement gives the error that "this" is read only. Now if I put it this way:

CODE:
Please log in to see this code.


it doesn't work either. For whatever reason all data in "ds" are zero after coming back to the strategy's calling code.

Any hints?
profile picture

Eugene

#2
QUOTE:
Could anyone make an example of a constructor of a custom indicator that just duplicates (i.e. calls) an already existing indicator?

Someone has already made an example - even better: there are tons of pointers in the open source code of the Community Indicators project:

Home - Community Indicators

Log in to the Wiki, grab the attachment, and perform a text search within solution. I see SMA.Series alone being references in 12 classes.
profile picture

Eugene

#3
QUOTE:
Second Question: Assume that I have a custom indicator called SMA_uni, and its constructor looks like this:

This is not going to work neither way. You should assign values on a bar by bar basis.
CODE:
Please log in to see this code.
profile picture

Ben_Zurich

#4
Thank you very much for your help. I was just missing a reference, and I was misled through the fact that the corresponding "using" statement showed no error.
profile picture

Ben_Zurich

#5
Second Question reply: This is a pity, as it can lead to multiple unneccessary processing and overall slowdown of the strategy and backtesting. Are you sure that there is no simpler way?
profile picture

Eugene

#6
Both the open source examples and the inidicator API tutorial teach you how to save an indicator's instance to the Cache and return its cached copy. If you do everything according to the examples provided, there will be no "slowdown of the Strategy" and no "unnecessary processing". Please just follow the examples, and do as I suggested. Every indicator out of those several hundreds that we already have, does what you're opposed to, and as you see, there ain't nothing like what you described.
profile picture

Ben_Zurich

#7
I have searched the WL and Wiki webpages but not found an indicator API tutorial. Where can I find it?
profile picture

Eugene

#8
It's here: Development Guide, the very first item.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).