Customized moving average for StochK
Author: lookingbackon
Creation Date: 4/16/2011 12:17 PM
profile picture

lookingbackon

#1
Hello,
I would like to have a smoothing moving average (K) of StochK with the following calculation method:

K(bar) = 2/3*K(bar-1)+ 1/3*StochK(bar)

I checked all available SMA in WLD indicator library and it seems like no one can fit the idea. Is it true? If yes, how can I make it?
Thanks
Barry
profile picture

Eugene

#2
Hope this helps:
CODE:
Please log in to see this code.
profile picture

Cone

#3
And another 1-liner way -
CODE:
Please log in to see this code.
profile picture

Eugene

#4
Nice one :)
profile picture

lookingbackon

#5
Hello Eugene and Cone,
Thanks a lot for the solution.
I just tried the code and find the code of the 2nd post exactly realized my idea. Although the "FIR.Series" way is quite convenient for use, but it seems fail to integrate "K(bar-1)" and "stochK(bar)" for "K(bar)" as the formular specified. The outcome data for these two method are different as well.
So it looks I gonna take the way of the 2nd post. Consequently, few questions for your further help:

(1) Is it possible at this moment to standardize/add the K as one of indicators with my WLD? So that I can quote it as normal indicators like e.g. StochK.

(2) If this is not the case. Then I have to integrate the code into my specific strategy coding. Given that, my question would be :
(A) Shall I just put the
CODE:
Please log in to see this code.
into my strategy code's main trading loop or separate loop is needed to generate the K.Series( although I don't think so)?
(B)If yes, what if I "SetScaleMonthly" for this K.Series? In my try practice, it seems can't work.

Would appreciate for your further help on that.
Barry
profile picture

Eugene

#6
(1) Yes, you can build an indicator library for your own formulas. There are numerous examples of such "formal" indicators (on the forum) and of course, the complete downloadable Community Indicators solution to serve as an example (from the Wiki).

(2A) A separate loop is not required.
(2B) In this case -- since one can't and shouldn't enter trades in a compressed scale like monthly -- a separate loop (prefaced with SetScaleMonthly; don't forget to restore scale thereafter) would be a solution.
profile picture

Cone

#7
QUOTE:
The outcome data for these two method are different as well.
Whoops, I made two mistakes. I got the order of the weights backwards, and worse, I didn't notice the IIR contruction, i.e., the first series was "K" and not "StochK". In that case, Eugene's method is the correct one.

We've got an IIRSmoother in TASCIndicators, but it's a different formulation. It might be a good idea to create a generalized IIR.Series indicator, similar to FIR.Series to specify weights and delays, but don't forget about the Gaussian and Butterworth IIR filters,
profile picture

lookingbackon

#8
Thanks Eugene and Cone. The desired "customized indicator" is available with my strategy code now:-)

I also checked the guideline on the wiki regarding how to create a own "formal" indicator and make it available to the indicator library(and eventually with WLD). Looks like quite complex. e.g.: .NET developing platform is needed.....

In this case, What I eventually would like to have is D which is the "Customized moving average" of K:

D(bar) = 2/3*D(bar-1)+ 1/3*K(bar)

Actually, the K and D are very popular indicators used in some of Asian stock market esp. in China. Meantime, the D can show quite stable medium-term trend with less volatility. Thus I think it would be better to make such "smoothing moving average" or K,D available with "community indicator".
profile picture

Eugene

#9
Sorry but the Community Indicators library is not the place to collect all single user solutions and indicator variations. Indicators of general recognition and utilitary DataSeries are usually included there since the library has a wide user base.
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).