How do I add an adjustable length moving average to the RSS efs as a signal line? Variables needed would be length of moving average, color, and type (sma,weighted,exp,dema,tema,hull).
In the RSS.efs formula, xRSS is the series object that contains this indicator. To do a moving average of it, all you need to do is pass it as the source to the moving average function.
Create a new global variable for the moving average, xMA.
Inside the bInit initialization code, initialize the xMA series as follows.
Add the current value of the xMA series to the return statement to plot it.
You may want to add some formatting settings to the preMain() code for the new plot as well.
You can take this further by adding more formula parameters to specify the length for the moving average and/or the type of the moving average as well. If you don't know how to add formula parameters, you may want to review section 3.4 Study Paramters (FunctionParameter Class) from Beginner Tutorial 3: Introduction to preMain() and main().
For the moving average types that are not built-in to EFS, you will have to program them into user-defined functions and call them from efsInternal(). Alternatively, you could put them into a custom EFS Function Library.
Jason K.
Project Manager eSignal - an Interactive Data company
I added a function parameter to the sma so I could have variable lengths and it works great. Don't think I'll mess with the too many types of smoothed signals though, as it doesn't seem necessary.
Comment