Displaced Moving Average
Author: StreetSmart
Creation Date: 7/11/2009 7:37 AM
profile picture

StreetSmart

#1
I am unable to find any technical indicator that is a Displaced Moving Average in the program (Simple Moving Average # of Periods, w/ # of Periods advancement). A very important indicator that I suspect is quite easy to code -- I just don't know how. Could this indicator be added? Thanks!
profile picture

Cone

#2
You can advance (peek) or delay any DataSeries using the shift operators, << (peek) and >>

See example in QuickRef (F11), click on DataSeries Object.
profile picture

Eugene

#3
It makes sense to add a displaced MA indicator to Community.Indicators solely for the users of rule-based strategies. It could have the choice of some basic MA types like EMA, SMA and WMA but would not be able to peak by advancing.
profile picture

StreetSmart

#4
I'm sorry... I can not find any reference to "peak" under the DataSeries Object In Quick Ref.

Eugene: Wouldn't this be a relatively simple indicator to add to the community? I would think just the Simple Moving Average (single indicator adjustable to number of periods) with the ability to advance by an adjustable number of periods would be adequate. I don't see that the complexity of adding EMA and WMA would be necessary. Thanks!
profile picture

Eugene

#5
Yes, that should be an easy task.
profile picture

Cone

#6
SS, it's "peek", not "peak".

When you say "advance", it sounds like you want to look at data from the future, i.e., move the series left (<<) in time. That's peeking. Almost always, the correct operation is to "delay" using the >> shift operator. Any rule-based Strategy should not include the ability to peek, so only a delay option can be provided for Rules.

Anyway, Eugene, I'm not clear on what you'll provide here. What is the Rule/Condition for a delayed series? What, precisely is SS asking for? Just a plot?
profile picture

Eugene

#7
Almost anything you could do with regular series, like CrossOver/CrossUnder or Price above/below, would apply for a delayed series (e.g. ActiveTrader Mag TSL 06/2007).
profile picture

Cone

#8
Of course, but are you going to create rules for all of them? If you are, do it for the General Indicators instead of just one.

Do we have a Community.Rules yet?
profile picture

Eugene

#9
Why the need to create rules, am I overlooking something? SS's idea was to create a shifted moving average series indicator.
profile picture

Cone

#10
And why do we need a new indicator for that?

SS, what's the purpose here? Plotting? Here's the code, and you can do the same thing for any indicator you want.

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

StreetSmart

#11
The Displaced MA is considered the premier "leading" indicator. The shift is actually advanced for the designated period rather than delayed. A well-known and frequently used indicator. Often times, depending on the time scale being used, the Displaced MA would be adjusted. (i.e., it might be a different set of values for one using a 5 minute chart as opposed to another using a monthly chart). Therefore, making it an adjustible indicator available among the community indicators would be of great value to all with out each having to code or change code to alter the indicator values. It's by no means an obscure indicator and the Displacement shift isn't appropriate or necessary for all indicators.

Example: A day trader might want a Displaced MA to have a 3 day SMA with the ability to displace it by 3 hours.
A trend trader might want a 25 day SMA and be able to displace it by 5 days.

I think this could be an invaluable tool for the WLP community and would be most grateful for your consideration of adding it.
Thank you!
profile picture

Cone

#12
QUOTE:
the premier "leading" indicator
It might be yours, but let me assure you that there is no one "premier leading indicator".

QUOTE:
3 day SMA with the ability to displace it by 3 hours
Eugene, the requirements just became a little more than trivial.


SS, which way is the displacement? (I just know you're going to tell me, "to the left").
profile picture

Eugene

#13
Agreed: displaced MAs are pretty far from being a leading indicator -- rather, in some cases it can help avoid false signals by reducing whipsaws. And "to the left" is not an option.
profile picture

StreetSmart

#14
No. Displaced to the right. Okay, maybe it's not your favorite indicator and maybe "leading indicator" isn't the the best nomenclature for it. But thats MY failing the not usefulness of the indicator's failing. It still can be a very useful indicator for many.

QUOTE:
Why the need to create rules, am I overlooking something? SS's idea was to create a shifted moving average series indicator.

Precisely!
QUOTE:
in some cases it can help avoid false signals by reducing whipsaws

Eugene, you're exactly right. The purpose is to reduce false signals and whipsaws. Wouldn't that have enough merit to justify it's existance? Not being a programmer myself, I can only guess that a SMA is very basic programming (and already existing). Coupling with it, an adjustment to shift its a value to the right a designated number of periods doesn't seem like a huge thing (except for me -- a non-programmer). Doable? Pleeeeaase? Pretty pleeeease? :)
profile picture

Eugene

#15
SS,

OK, a displaced MA indicator is going to make it in the next update of Community.Indicators -- without the ability to peak ahead and displace a daily SMA by X hours (as Robert noted, this complicates the solution).
profile picture

Cone

#16
Eugene, instead of creating a new indicator that just delays an already delayed signal, why don't you just create the "ShiftDelay Indicator". That way, it can dragged and dropped on any plotted series or indicator.
profile picture

Eugene

#17
OK good, then we'll have 2 indicators:

* the ShiftDelay indicator for visual backtesting (as it can't be utilized in a General Indicators rule for something else than O,H,L,C), and
* the shifted MA to be used in rule-based strategies.
profile picture

StreetSmart

#18
Excellent solution!
Thanks, guys.
profile picture

Eugene

#19
Both these indicators have been coded, will appear early August in Community.Indicators.
profile picture

Eugene

#20
StreetSmart, you may now download the updated library.
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).