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

[EquisMetaStock Group] Momentum errors



PureBytes Links

Trading Reference Links



Momentum is one of the most basic yet useful trading tools.
Standard Momentum indicator formula:

===================
Momentum - standard
===================
---8<--------------

{ User inputs }
pds:=Input("Time periods",1,252,12);
pf:=Input("Price field: [1]Open, [2]High, [3]Low, [4]Close",1,4,4);

{ Choose price field }
x:=If(pf=1,O,If(pf=2,H,If(pf=3,L,C)));

{ Momentum }
PrevBar:=Ref(x,-pds);
Mom:=x/PrevBar*100;

{ Plot in own window }
100;Mom

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


The above indicator plots identical values to the standard MetaStock 
version.
It also allows us to replace the x variable with other data than the 
usual OHLC.

Ok, let's do that.
Replacing price field with Price Oscillator:

=============
Momentum - PO
=============
---8<--------------

{ User inputs }
pds:=Input("Time periods",1,252,12);

{ Price Oscillator }
x:=OscP(5,21,E,%);

{ Momentum }
PrevBar:=Ref(x,-pds);
Mom:=x/PrevBar*100;

{ Plot in own window }
100;Mom

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

Ignoring the zero-crossing spikes for the time being, notice how Price 
Oscillator negative values force Momentum to flip and produce errors:
POsc negative values create a positive Momentum plot.

This can be a real problem, not just with experimental inputs into the 
Momentum price field, but also when applying Momentum to any data 
series that includes negative values, such as some back-adjusted 
contracts.

So, here is a solution:

===================
Momentum - absolute
===================
---8<--------------

{ User inputs }
pds:=Input("Time periods",1,252,12);
pf:=Input("Price: [1]Open, [2]High, [3]Low, [4]Close, [5]WC",1,5,4);

{ Choose price field }
x:=If(pf=1,O,If(pf=2,H,If(pf=3,L,
 If(pf=5,WC(),C))));

{ Replace price field with indicator/oscillator}
{x:=OscP(5,21,E,%);}

{ Absolute Momentum }
PrevBar:=Ref(x,-pds);
Difference:=x-PrevBar;
AbsChange:=Abs(Difference/PrevBar)*100;
Mom:=If(Difference>0,AbsChange,-AbsChange)+100;

{ Plot in own window }
100;Mom

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

The Momentum indicator above still plots identical values to 
MetaStock's when applying it to positive data, and yet it also plots 
correct values when negative data is used.


jose '-)






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

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

<*> 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/