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

[Metastockusers] signal-frequency self-adjusting EMA



PureBytes Links

Trading Reference Links


This self-adjusting EMA indicator adjusts its periodicity to crossover 
signals frequency.  Beware - it uses hindsight to determine trade 
frequency.


MetaStock -> Tools -> Indicator Builder -> New
Copy and paste formula below.

====================
EMA - trade-adjusted
====================
---8<---------------------------

{ 6-loop trade-adjusted EMA }
{ Adjusts EMA periodicity to trade frequency }

{ ©Copyright 2005 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 }
avg:=Input("Crossover trades per year",
 2,1000,12);
plot:=Input("[1]EMA,  [2]Signals,  [3]EMA periods",1,3,1);

{ Base EMA periods }
pds:=21;

{ Year count }
yCount:=
 LastValue(Year()-ValueWhen(1,Cum(1)=1,Year()));

{ Loop 1 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 2 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 3 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 4 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 5 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Loop 6 }
signal:=Cross(C,Mov(C,pds,E));
pds:=Int(Cum(signal)/yCount/avg*pds+.5);
pds:=LastValue(If(pds<2,2,pds));

{ Final output }
EMA:=Mov(C,pds,E);
long:=Cross(C,EMA);
short:=Cross(EMA,C);

{ Plot EMA on price chart }
If(plot=1,EMA,If(plot=2,long-short,pds))

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


jose '-)
http://www.metastocktools.com









------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/zMEolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

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

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

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