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

[EquisMetaStock Group] MACD oscillator signals



PureBytes Links

Trading Reference Links

Posted recently in 
http://finance.groups.yahoo.com/group/metastocktips

---------------------------------------------------

Contrary to popular belief, signals based on oscillator trigger 
crossovers are seldom profitable.  By the time the oscillator 
crosses its signal line, most of the security's profit has 
passed.  This is specially true in market sideways periods.

A more profitable signal can be obtained by using overBought/Sold 
levels of the oscillator to trigger entries.  This is only 
possible when using automatic overBought/Sold levels which adjust 
for each individual security's price volatility, as in the 
indicator below.


=========================
MACD oscillator - Signals
=========================
---8<---------------------------------------

{ Stochastic-normalized MACD signals v3.0
  Incorporating auto overbought/sold signals.

  Warning:
   Trade these signals at your own risk!

 ©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("Stochastic (cycle) lookback periods",2,252,63);
pds1:=Input("short EMA periods",1,252,12);
pds2:=Input("long EMA periods",2,2520,26);
pds3:=Input("MACD oscillator trigger periods",
 1,252,21);
z:=Input("use Open=1 High=2 Low=3 Close=4 WhgtCl=5 Vol=6",1,6,4);

{ Chosen data array }
z:=If(z=1,O,If(z=2,H,If(z=3,L,If(z=5,WC(),If(z=6,V,C)))));

{ MACD normalized }
x:=Mov(z,pds1,E);
y:=Mov(z,pds2,E);
ratio:=Min(x,y)/Max(x,y);
Mac:=(If(x>y,2-ratio,ratio)-1)*100;

{ Stochastic MACD }
osc:=(Mac-LLV(Mac,pds))
 /Max(HHV(Mac,pds)-LLV(Mac,pds),.000001)*100;
avg:=Cum(osc)/Cum(IsDefined(osc));

{ Auto overbought/sold levels }
pk:=Ref(osc,-1)=HHV(osc,3) AND osc>avg;
oBought:=ValueWhen(1,pk,Ref(osc,-1))*pk;
oBought:=Cum(oBought)/Cum(pk);
tr:=Ref(osc,-1)=LLV(osc,3) AND osc<avg;
oSold:=ValueWhen(1,tr,Ref(osc,-1))*tr;
oSold:=Cum(oSold)/Cum(tr);

{ Overbought/sold crossover signals }
signals:=Cross(osc,oSold)-Cross(osc,oBought);

{ Plot in own window }
signals

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

Exploration code for above signals:
Fml("MACD oscillator - Signals")


The original indicator:

====================================
MACD oscillator - Schaff Trend Cycle
====================================
---8<---------------------------------------

{ Stochastic-normalized MACD v2.0
  Incorporating auto overbought/sold levels.

 ©Copyright 2005-2006 Jose Silva.
  For personal use only.
  http://www.metastocktools.com }

{ User inputs }
pds:=Input("Stochastic (cycle) lookback periods",2,252,63);
pds1:=Input("short EMA periods",1,252,12);
pds2:=Input("long EMA periods",2,2520,26);
pds3:=Input("MACD oscillator trigger signal periods",1,252,21);
z:=Input("use Open=1 High=2 Low=3 Close=4 WhgtCl=5 Vol=6",1,6,4);
plot:=Input("[1]MACD osc,  [2]Histogram,  [3]trigger Signals",1,
3,1);

{ Chosen data array }
z:=If(z=1,O,If(z=2,H,If(z=3,L,If(z=5,WC(),If(z=6,V,C)))));

{ MACD normalized }
x:=Mov(z,pds1,E);
y:=Mov(z,pds2,E);
ratio:=Min(x,y)/Max(x,y);
Mac:=(If(x>y,2-ratio,ratio)-1)*100;

{ Stochastic MACD }
StochMac:=(Mac-LLV(Mac,pds))
 /Max(HHV(Mac,pds)-LLV(Mac,pds),.000001)*100;
trigger:=Mov(StochMac,pds3,E);
hist:=StochMac-trigger;
osc:=If(plot=1,StochMac,hist);
avg:=Cum(osc)/Cum(IsDefined(osc));

{ Auto overbought/sold levels }
pk:=Ref(osc,-1)=HHV(osc,3) AND osc>avg;
oBought:=ValueWhen(1,pk,Ref(osc,-1))*pk;
oBought:=Cum(oBought)/Cum(pk);
tr:=Ref(osc,-1)=LLV(osc,3) AND osc<avg;
oSold:=ValueWhen(1,tr,Ref(osc,-1))*tr;
oSold:=Cum(oSold)/Cum(tr);

{ Trigger crossover signals }
signals:=Cross(StochMac,trigger)
 -Cross(trigger,StochMac);

{ Plot in own window.               Plot color:}
If(plot=3,0,oBought);               { <- Grey  }
If(plot=3,0,avg);                   { <- Grey  }
If(plot=3,0,oSold);                 { <- Grey  }
If(plot=1,trigger,If(plot=2,osc,0));{ <- Green }
If(plot=3,signals,osc)              { <- Red   }

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

Exploration code for trigger crossover signals (not recommended):
FmlVar("MACD oscillator - Schaff Trend Cycle","SIGNALS")


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





--- In metastocktips@xxxxxxxxxxxxxxx, "Kevin and Heather Howard" 
<kjhoward@xxx> wrote:
>
> Hi,
> 
> Jose has this brilliant Indicator on his web site and I wonder
> if others have tried it. I appreciate that it is an oscillator
> but I am interested in the cross over points of the two lines
> it plots.
> 
> Is it possible to rework the code so that it can be used within
> an exploration to find stocks where a cross over has taken
> place?  
> 
> Jose's site as most would know is at:
> http://www.metastocktools.com/index.html
> 
> Any help would be greatly appreciated.
>
>
> Best wishes,
> 
> Kevin


---------------------------------------------------








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Home is just a click away.  Make Yahoo! your home page now.
http://us.click.yahoo.com/DHchtC/3FxNAA/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/