[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: every x period moving average



PureBytes Links

Trading Reference Links

juzam,

Not sure exactly what you are looking for. 

Here are several ideas though to consider. 

A weekly plot will plot every friday or 5th day of the week. Roy and 
Jose have both written indicators for this and you can check their 
sites for the weekly indicators. Here's one from Jose's site that does 
what you asked for except the smoothing:

==================================
Periodicity marker and OHLC values
==================================
---8<-------------------------------

{ Signals Nth bar periodicity - v2.2

 ©Copyright 2004~2006 Jose Silva.
  The grant of this license is for personal use
   only - no resale or repackaging allowed.
  All code remains the property of Jose Silva.
  http://www.metastocktools.com }

{ User inputs }
pds:=Input("Nth bar periodicity",1,252,21);
plot:=Input("plot:  [1]Signals,  [2]OHLC",
 1,2,1);

{ Nth bar signals }
signal:=Mod(Cum(1),pds)=0;

{ Nth bar OHLC values }
Op:=ValueWhen(1,signal,O);
Hi:=HighestSince(1,signal,H);
Lo:=LowestSince(1,signal,L);
Cl:=ValueWhen(1,signal,Ref(C,-1));

{ Plot signals in own window;
   plot OHLC values on chart }
If(plot=1,0,Op);     { Green }
If(plot=1,0,Hi);     { Blue  }
If(plot=1,0,Lo);     { Red   }
If(plot=1,signal,Cl) { Black }

---8<-------------------------------


The problem that you have with this indicator is that it is not very 
smooth. It will plot a day and then hold that value until the next 
period is cycled. The output looks like stairsteps.


You can also rewrite Jose's code to something like this:

pds:=Input("Nth bar periodicity",1,252,5);
pdsma:=Input("Smoothing periods",1,100,21);
signal:=Mod(Cum(1),pds)=0;
Cl:=ValueWhen(1,signal,Ref(C,-1));
mov(Cl,pdsma,S){end}


Your request though is for an x period moving average. Why not simply 
smooth an x period moving average like this:

mov(mov(c,5,s),20,s)

The output is a 5 day moving average smoothed 20 days.

Hope this helps,


Preston


 

--- In equismetastock@xxxxxxxxxxxxxxx, juzam66666 <no_reply@xxx> wrote:
>
> hi all,
> 
> i was curious if anyone knew how to create a moving average that 
> averaged every x periods. it would be like a regular moving average, 
> except it would skip....for example, a 20day sma with x=2, it would 
> average every other day for 20 periods. x=5 would average every 5 
days 
> for 20 periods.
> 
> appreciate any help you can offer.
>




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Transfer from your equities account.  
Receive up to $1,000 from GFT. Click here to learn more.
http://us.click.yahoo.com/aZttyC/X_xQAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/