Saved MACD indicator for modification into PPO Indicator.
Equations for MACD and PPO listed below
MACD Line = 12EMA - 26EMA
Signal Line = 9EMA of MACD Line
Histogram = MACD Line - Signal Line
PPO Line = (12EMA-26EMA)/26EMA
Signal Line = 9EMA of PPO Line
Histogram = PPO Line - Signal Line
_____________________________________________________________
Here is the modified
EasyLanguage MACD Code I created:
{
Moving average convergence-
divergence indicator Modified for PPO }
inputs:
int FastLength( 12 ), { the shorter of the two exponential moving average
lengths used to calculate the MACD value, in bars }
int SlowLength( 26 ), { the longer of the two exponential moving average
lengths used to calculate the MACD value, in bars }
int MACDLength( 9 ), { the number of bars over which to exponentially average
the MACD value }
int MACDDiff_Up_Color( Darkgreen ), { color to be used to plot positive values of
MACDDiff }
int MACDDiff_Down_Color( Red ), { color to be used to plot negative values of
MACDDiff }
int BackgroundColorAlertCell( DarkGray ) ; { if alert criteria are met, this is
the color used for the cell background in RadarScreen; if it is not desired
for the cell background color to change when the alert criteria are met, set
this input to the default cell background color }
variables:
intrabarpersist bool PlotCrossBarsAgo( false ),
double MyMACD( 0 ),
double MACDAvg( 0 ),
double MACDDiff( 0 ),
double SlowlengthEMA (0),
double PPO1 (0), {PPO is TradeStation reserved word, used PPO1 instead for PPO}
double HistogramColor( 0 ),
int CrossBarsAgo( 0 ) ;
once
PlotCrossBarsAgo = GetAppInfo( aiApplicationType ) <> cChart ;
MyMACD = MACD( Close, FastLength, SlowLength ) ;
SlowlengthEMA = XAverage (Close,Slowlength);
MACDAvg = XAverage( MyMACD, MACDLength ) ;
PPO1 = MyMACD/MACDAvg;
MACDDiff = PPO1 - MACDAvg ;
HistogramColor = iff( MACDDiff > 0, MACDDiff_Up_Color, MACDDiff_Down_Color ) ;
if ( MACDDiff > 0 and MACDDiff[1] <= 0 ) or ( MACDDiff < 0 and MACDDiff[1] >= 0 )
then
CrossBarsAgo = 0
else
CrossBarsAgo += 1 ;
Plot1( PPO1, "PPO" ) ;
Plot2( MACDAvg, "PPO Signal" ) ;
Plot3( MACDDiff, "PPO Hist", HistogramColor ) ;
if PlotCrossBarsAgo = false then
Plot4( 0, "ZeroLine" )
else
Plot5( CrossBarsAgo, "CrossBarsAgo", HistogramColor ) ;
{ alert criteria }
if MACDDiff crosses over 0 then
begin
SetPlotBGColor( 5, BackgroundColorAlertCell ) ;
Alert( "MACD diff. crossing over 0." ) ;
end
else if MACDDiff crosses under 0 then
begin
SetPlotBGColor( 5, BackgroundColorAlertCell ) ;
Alert( "MACD diff. crossing under 0." ) ;
end ;
{ ** Copyright (c) 2001 - 2011 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this analysis technique
with each release. ** }