TRIX above or below a smoothed average
Author: M635
Creation Date: 3/4/2009 8:20 PM
profile picture

M635

#1

New user here,, not a coder but trying!

Want to create a couple of indicators using TRIX and OBV above or below a smoothed SMA. Used the code lines shown below in a script I created with the rules builder in WL 5.

if (TRIX.Series(Close,5)[bar] > SMA.Series(TRIX.Series(Close,5), 15))
{
if(OBV.Series(Bars)[bar] > SMA.Series(OBV.Series(Bars), 24))

Error message returned for both lines was, error CS0019 Operator">" cannot be applied to operands of type "double" and "Wealth lab indicators SMA"

Is it true that you can not create a smoothed average indicator of OBV and TRIX, or do my lines of code have other errors in them?

Any advice or help appreciated.


profile picture

DartboardTrader

#2
That is fairly inefficient, and there is a coding mistake (the compiler is accurately telling you what is wrong.)
To correct the coding mistake, use:

CODE:
Please log in to see this code.


However, you are creating a complete series for each bar you inspect.
Expect this strategy to run fairly slow, unless caching takes place behind the scenes.

What you may want is the below. Create your data series before the loop, since you really want to inspect these values each step through the "Bars" loop.

CODE:
Please log in to see this code.
profile picture

Cone

#3
QUOTE:
unless caching takes place behind the scenes.
All integrated indicators use caching, so either method is okay. The only time that an indicator would be recalculated (for the same parameters) is for its .Value method (if supported).
profile picture

Cone

#4
QUOTE:
unless caching takes place behind the scenes.
All integrated indicators use caching, so either method is okay. The only time that an indicator would be recalculated (for the same parameters) is for its .Value method (if supported).
profile picture

M635

#5
Thanks to all for the great advice and help!!!

I am going to give these a try, may be back again for more help.
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).