log in     sign up for free
 
Don't worry about what the markets are going to do, worry about what you are going to do in response to the markets.
Michael Carr
 
 
Home
systems (284)
 
Special offer: buy AmiBroker and EOD+Real-Time Data
 

Buy

MetaStock

     (special offer)
 
 
 

Buy

EOD data for MetaStock

     (special offer)
 
 
 

Buy

Realtime data for MetaStock

     (special offer)
 
 
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

MACD Oscillator - Schaff Trend Cycle V2.0

Formula for: MetaStock

indicator


 

 

Views:  1677

Added: December 03, 2006
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: MetaStock, indicator
 
Your Ad Here
Stochastic-normalized MACD oscillator / Schaff Trend Cycle, multiple output choice, signals.

 

 



Code:


MACD oscillator - Schaff Trend Cycle



{ 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 }


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.



MACD oscillator - Signals


 

{ 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


 






Author: Jose Silva
Source: http://www.metastocktools.com/

 

View similar (indicator for MetaStock):

Trading the Trend II (TTT)
Linia Obrony ATR Op
WinMidas - Support and Resistance Levels
Kurtosis Exact
True Range Formula
Volume Accumulator (Chaikin)
William\'s Trough
Smoothing Techniques
Calibrated Summation Index
Volatility Breakout System - Returns Profit
...
 
 
all formulas for MetaStock
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
 
Privacy note | (c) copyrights systems4trading.com 2006-2012